code
stringlengths
130
281k
code_dependency
stringlengths
182
306k
public class class_name { private SolrServer initCore(String coreName) { try { String uri = config.getString(null, "indexer", coreName, "uri"); if (uri == null) { log.error("No URI provided for core: '{}'", coreName); return null; } URI solrUri = new URI(uri); CommonsHttpSolrServer thisCore = new CommonsHttpSolrServer(solrUri.toURL()); String username = config.getString(null, "indexer", coreName, "username"); String password = config.getString(null, "indexer", coreName, "password"); usernameMap.put(coreName, username); passwordMap.put(coreName, password); if (username != null && password != null) { UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); HttpClient hc = (thisCore).getHttpClient(); hc.getParams().setAuthenticationPreemptive(true); hc.getState().setCredentials(AuthScope.ANY, credentials); } return thisCore; } catch (MalformedURLException mue) { log.error(coreName + " : Malformed URL", mue); } catch (URISyntaxException urise) { log.error(coreName + " : Invalid URI", urise); } return null; } }
public class class_name { private SolrServer initCore(String coreName) { try { String uri = config.getString(null, "indexer", coreName, "uri"); if (uri == null) { log.error("No URI provided for core: '{}'", coreName); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } URI solrUri = new URI(uri); CommonsHttpSolrServer thisCore = new CommonsHttpSolrServer(solrUri.toURL()); String username = config.getString(null, "indexer", coreName, "username"); String password = config.getString(null, "indexer", coreName, "password"); usernameMap.put(coreName, username); // depends on control dependency: [try], data = [none] passwordMap.put(coreName, password); // depends on control dependency: [try], data = [none] if (username != null && password != null) { UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); HttpClient hc = (thisCore).getHttpClient(); hc.getParams().setAuthenticationPreemptive(true); // depends on control dependency: [if], data = [none] hc.getState().setCredentials(AuthScope.ANY, credentials); // depends on control dependency: [if], data = [none] } return thisCore; // depends on control dependency: [try], data = [none] } catch (MalformedURLException mue) { log.error(coreName + " : Malformed URL", mue); } catch (URISyntaxException urise) { // depends on control dependency: [catch], data = [none] log.error(coreName + " : Invalid URI", urise); } // depends on control dependency: [catch], data = [none] return null; } }
public class class_name { @Override public void process(List<EllipseRotated_F64> ellipses , List<List<EllipsesIntoClusters.Node>> clusters ) { foundGrids.reset(); for (int i = 0; i < clusters.size(); i++) { List<EllipsesIntoClusters.Node> cluster = clusters.get(i); int clusterSize = cluster.size(); if( clusterSize < 2 ) continue; computeNodeInfo(ellipses, cluster); // finds all the nodes in the outside of the cluster if( !findContour(false) ) { if( verbose ) System.out.println("Contour find failed"); continue; } // Find corner to start alignment NodeInfo corner = selectSeedCorner(); corner.marked = true; boolean ccw = UtilAngle.distanceCCW(direction(corner,corner.right),direction(corner,corner.left)) > Math.PI; // find the row and column which the corner is a member of List<NodeInfo> cornerRow = findLine(corner,corner.left,clusterSize, null,ccw); List<NodeInfo> cornerColumn = findLine(corner,corner.right,clusterSize, null,!ccw); if( cornerRow == null || cornerColumn == null ) { if( verbose )System.out.println("Corner row/column line find failed"); continue; } // Go down the columns and find each of the rows List<List<NodeInfo>> gridByRows = new ArrayList<>(); gridByRows.add( cornerRow ); boolean failed = false; for (int j = 1; j < cornerColumn.size(); j++) { List<NodeInfo> prev = gridByRows.get( j - 1); NodeInfo seed = cornerColumn.get(j); NodeInfo next = selectSeedNext(prev.get(0),prev.get(1), seed,ccw); if( next == null ) { if( verbose ) System.out.println("Outer column with a row that has only one element"); failed = true; break; } List<NodeInfo> row = findLine( seed , next, clusterSize, null,ccw); gridByRows.add( row ); } if( failed ) continue; // perform sanity checks if( !checkGridSize(gridByRows, cluster.size()) ) { if( verbose ) { System.out.println("grid size check failed"); for (int j = 0; j < gridByRows.size(); j++) { System.out.println(" row "+gridByRows.get(j).size()); } } continue; } if( checkDuplicates(gridByRows) ) { if( verbose ) System.out.println("contains duplicates"); continue; } createRegularGrid(gridByRows,foundGrids.grow()); } } }
public class class_name { @Override public void process(List<EllipseRotated_F64> ellipses , List<List<EllipsesIntoClusters.Node>> clusters ) { foundGrids.reset(); for (int i = 0; i < clusters.size(); i++) { List<EllipsesIntoClusters.Node> cluster = clusters.get(i); int clusterSize = cluster.size(); if( clusterSize < 2 ) continue; computeNodeInfo(ellipses, cluster); // depends on control dependency: [for], data = [none] // finds all the nodes in the outside of the cluster if( !findContour(false) ) { if( verbose ) System.out.println("Contour find failed"); continue; } // Find corner to start alignment NodeInfo corner = selectSeedCorner(); corner.marked = true; // depends on control dependency: [for], data = [none] boolean ccw = UtilAngle.distanceCCW(direction(corner,corner.right),direction(corner,corner.left)) > Math.PI; // find the row and column which the corner is a member of List<NodeInfo> cornerRow = findLine(corner,corner.left,clusterSize, null,ccw); List<NodeInfo> cornerColumn = findLine(corner,corner.right,clusterSize, null,!ccw); if( cornerRow == null || cornerColumn == null ) { if( verbose )System.out.println("Corner row/column line find failed"); continue; } // Go down the columns and find each of the rows List<List<NodeInfo>> gridByRows = new ArrayList<>(); gridByRows.add( cornerRow ); // depends on control dependency: [for], data = [none] boolean failed = false; for (int j = 1; j < cornerColumn.size(); j++) { List<NodeInfo> prev = gridByRows.get( j - 1); NodeInfo seed = cornerColumn.get(j); NodeInfo next = selectSeedNext(prev.get(0),prev.get(1), seed,ccw); if( next == null ) { if( verbose ) System.out.println("Outer column with a row that has only one element"); failed = true; // depends on control dependency: [if], data = [none] break; } List<NodeInfo> row = findLine( seed , next, clusterSize, null,ccw); gridByRows.add( row ); // depends on control dependency: [for], data = [none] } if( failed ) continue; // perform sanity checks if( !checkGridSize(gridByRows, cluster.size()) ) { if( verbose ) { System.out.println("grid size check failed"); // depends on control dependency: [if], data = [none] for (int j = 0; j < gridByRows.size(); j++) { System.out.println(" row "+gridByRows.get(j).size()); // depends on control dependency: [for], data = [j] } } continue; } if( checkDuplicates(gridByRows) ) { if( verbose ) System.out.println("contains duplicates"); continue; } createRegularGrid(gridByRows,foundGrids.grow()); // depends on control dependency: [for], data = [none] } } }
public class class_name { @Generated(value = "com.sun.tools.xjc.Driver", date = "2018-10-12T02:52:47+02:00", comments = "JAXB RI v2.2.11") public TypenHausKategorienTyp getObjektkategorie2() { if (objektkategorie2 == null) { return TypenHausKategorienTyp.KEINE_ANGABE; } else { return objektkategorie2; } } }
public class class_name { @Generated(value = "com.sun.tools.xjc.Driver", date = "2018-10-12T02:52:47+02:00", comments = "JAXB RI v2.2.11") public TypenHausKategorienTyp getObjektkategorie2() { if (objektkategorie2 == null) { return TypenHausKategorienTyp.KEINE_ANGABE; // depends on control dependency: [if], data = [none] } else { return objektkategorie2; // depends on control dependency: [if], data = [none] } } }
public class class_name { public static String wellFormedToFS(Part value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); } return value.getAbbreviation(); } }
public class class_name { public static String wellFormedToFS(Part value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); // depends on control dependency: [if], data = [none] } return value.getAbbreviation(); } }
public class class_name { private GribCollectionProto.Group writeGroupProto(Group g) { GribCollectionProto.Group.Builder b = GribCollectionProto.Group.newBuilder(); b.setGds(writeGdsProto(g.gdss.getRawBytes(), g.gdss.getPredefinedGridDefinition())); for (Grib1CollectionBuilder.VariableBag vbag : g.gribVars) { b.addVariables(writeVariableProto(vbag)); } for (Coordinate coord : g.coords) { switch (coord.getType()) { case runtime: b.addCoords(writeCoordProto((CoordinateRuntime) coord)); break; case time: b.addCoords(writeCoordProto((CoordinateTime) coord)); break; case timeIntv: b.addCoords(writeCoordProto((CoordinateTimeIntv) coord)); break; case time2D: b.addCoords(writeCoordProto((CoordinateTime2D) coord)); break; case vert: b.addCoords(writeCoordProto((CoordinateVert) coord)); break; case ens: b.addCoords(writeCoordProto((CoordinateEns) coord)); break; } } for (Integer aFileSet : g.fileSet) { b.addFileno(aFileSet); } return b.build(); } }
public class class_name { private GribCollectionProto.Group writeGroupProto(Group g) { GribCollectionProto.Group.Builder b = GribCollectionProto.Group.newBuilder(); b.setGds(writeGdsProto(g.gdss.getRawBytes(), g.gdss.getPredefinedGridDefinition())); for (Grib1CollectionBuilder.VariableBag vbag : g.gribVars) { b.addVariables(writeVariableProto(vbag)); // depends on control dependency: [for], data = [vbag] } for (Coordinate coord : g.coords) { switch (coord.getType()) { case runtime: b.addCoords(writeCoordProto((CoordinateRuntime) coord)); break; case time: b.addCoords(writeCoordProto((CoordinateTime) coord)); break; case timeIntv: b.addCoords(writeCoordProto((CoordinateTimeIntv) coord)); break; case time2D: b.addCoords(writeCoordProto((CoordinateTime2D) coord)); break; case vert: b.addCoords(writeCoordProto((CoordinateVert) coord)); break; case ens: b.addCoords(writeCoordProto((CoordinateEns) coord)); break; } } for (Integer aFileSet : g.fileSet) { b.addFileno(aFileSet); // depends on control dependency: [for], data = [aFileSet] } return b.build(); } }
public class class_name { public static Method getRequiredMethod(Class type, String name, Class... argumentTypes) { try { return type.getDeclaredMethod(name, argumentTypes); } catch (NoSuchMethodException e) { return findMethod(type, name, argumentTypes) .orElseThrow(() -> newNoSuchMethodError(type, name, argumentTypes)); } } }
public class class_name { public static Method getRequiredMethod(Class type, String name, Class... argumentTypes) { try { return type.getDeclaredMethod(name, argumentTypes); // depends on control dependency: [try], data = [none] } catch (NoSuchMethodException e) { return findMethod(type, name, argumentTypes) .orElseThrow(() -> newNoSuchMethodError(type, name, argumentTypes)); } // depends on control dependency: [catch], data = [none] } }
public class class_name { @Override public void doBootstrap(TransportClient client, Channel channel) { SparkSaslClient saslClient = new SparkSaslClient(appId, secretKeyHolder, conf.saslEncryption()); try { byte[] payload = saslClient.firstToken(); while (!saslClient.isComplete()) { SaslMessage msg = new SaslMessage(appId, payload); ByteBuf buf = Unpooled.buffer(msg.encodedLength() + (int) msg.body().size()); msg.encode(buf); buf.writeBytes(msg.body().nioByteBuffer()); ByteBuffer response = client.sendRpcSync(buf.nioBuffer(), conf.authRTTimeoutMs()); payload = saslClient.response(JavaUtils.bufferToArray(response)); } client.setClientId(appId); if (conf.saslEncryption()) { if (!SparkSaslServer.QOP_AUTH_CONF.equals(saslClient.getNegotiatedProperty(Sasl.QOP))) { throw new RuntimeException( new SaslException("Encryption requests by negotiated non-encrypted connection.")); } SaslEncryption.addToChannel(channel, saslClient, conf.maxSaslEncryptedBlockSize()); saslClient = null; logger.debug("Channel {} configured for encryption.", client); } } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { if (saslClient != null) { try { // Once authentication is complete, the server will trust all remaining communication. saslClient.dispose(); } catch (RuntimeException e) { logger.error("Error while disposing SASL client", e); } } } } }
public class class_name { @Override public void doBootstrap(TransportClient client, Channel channel) { SparkSaslClient saslClient = new SparkSaslClient(appId, secretKeyHolder, conf.saslEncryption()); try { byte[] payload = saslClient.firstToken(); while (!saslClient.isComplete()) { SaslMessage msg = new SaslMessage(appId, payload); ByteBuf buf = Unpooled.buffer(msg.encodedLength() + (int) msg.body().size()); msg.encode(buf); // depends on control dependency: [while], data = [none] buf.writeBytes(msg.body().nioByteBuffer()); // depends on control dependency: [while], data = [none] ByteBuffer response = client.sendRpcSync(buf.nioBuffer(), conf.authRTTimeoutMs()); payload = saslClient.response(JavaUtils.bufferToArray(response)); // depends on control dependency: [while], data = [none] } client.setClientId(appId); // depends on control dependency: [try], data = [none] if (conf.saslEncryption()) { if (!SparkSaslServer.QOP_AUTH_CONF.equals(saslClient.getNegotiatedProperty(Sasl.QOP))) { throw new RuntimeException( new SaslException("Encryption requests by negotiated non-encrypted connection.")); } SaslEncryption.addToChannel(channel, saslClient, conf.maxSaslEncryptedBlockSize()); // depends on control dependency: [if], data = [none] saslClient = null; // depends on control dependency: [if], data = [none] logger.debug("Channel {} configured for encryption.", client); // depends on control dependency: [if], data = [none] } } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { // depends on control dependency: [catch], data = [none] if (saslClient != null) { try { // Once authentication is complete, the server will trust all remaining communication. saslClient.dispose(); // depends on control dependency: [try], data = [none] } catch (RuntimeException e) { logger.error("Error while disposing SASL client", e); } // depends on control dependency: [catch], data = [none] } } } }
public class class_name { private Map<String, Macro> parsePredefinedUnitMacros(Map<String, Macro> configuredMacros) { if (!ctorInProgress || (unitMacros != null)) { throw new IllegalStateException("Preconditions for initial fill-out of predefinedUnitMacros were violated"); } if (conf.getCompilationUnitSourceFiles().isEmpty() && (conf.getGlobalCompilationUnitSettings() == null)) { // configuration doesn't contain any settings for compilation units. // CxxPreprocessor will use fixedMacros only return Collections.emptyMap(); } unitMacros = new MapChain<>(); if (getMacros() != unitMacros) { throw new IllegalStateException("expected unitMacros as active macros map"); } try { getMacros().setHighPrio(true); getMacros().putAll(Macro.UNIT_MACROS); getMacros().putAll(configuredMacros); parseForcedIncludes(); final HashMap<String, Macro> result = new HashMap<>(unitMacros.getHighPrioMap()); return result; } finally { getMacros().setHighPrio(false); // just for the symmetry unitMacros = null; // remove unitMacros, switch getMacros() to fixedMacros } } }
public class class_name { private Map<String, Macro> parsePredefinedUnitMacros(Map<String, Macro> configuredMacros) { if (!ctorInProgress || (unitMacros != null)) { throw new IllegalStateException("Preconditions for initial fill-out of predefinedUnitMacros were violated"); } if (conf.getCompilationUnitSourceFiles().isEmpty() && (conf.getGlobalCompilationUnitSettings() == null)) { // configuration doesn't contain any settings for compilation units. // CxxPreprocessor will use fixedMacros only return Collections.emptyMap(); // depends on control dependency: [if], data = [none] } unitMacros = new MapChain<>(); if (getMacros() != unitMacros) { throw new IllegalStateException("expected unitMacros as active macros map"); } try { getMacros().setHighPrio(true); getMacros().putAll(Macro.UNIT_MACROS); getMacros().putAll(configuredMacros); parseForcedIncludes(); final HashMap<String, Macro> result = new HashMap<>(unitMacros.getHighPrioMap()); return result; } finally { getMacros().setHighPrio(false); // just for the symmetry unitMacros = null; // remove unitMacros, switch getMacros() to fixedMacros } } }
public class class_name { private void lostConnection(final MemcachedNode node) { queueReconnect(node); for (ConnectionObserver observer : connObservers) { observer.connectionLost(node.getSocketAddress()); } } }
public class class_name { private void lostConnection(final MemcachedNode node) { queueReconnect(node); for (ConnectionObserver observer : connObservers) { observer.connectionLost(node.getSocketAddress()); // depends on control dependency: [for], data = [observer] } } }
public class class_name { public void setResourceAwsEc2InstanceKeyName(java.util.Collection<StringFilter> resourceAwsEc2InstanceKeyName) { if (resourceAwsEc2InstanceKeyName == null) { this.resourceAwsEc2InstanceKeyName = null; return; } this.resourceAwsEc2InstanceKeyName = new java.util.ArrayList<StringFilter>(resourceAwsEc2InstanceKeyName); } }
public class class_name { public void setResourceAwsEc2InstanceKeyName(java.util.Collection<StringFilter> resourceAwsEc2InstanceKeyName) { if (resourceAwsEc2InstanceKeyName == null) { this.resourceAwsEc2InstanceKeyName = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.resourceAwsEc2InstanceKeyName = new java.util.ArrayList<StringFilter>(resourceAwsEc2InstanceKeyName); } }
public class class_name { private <R> R doWithWriteLock(Action<K, V, R> action) { long stamp = sl.writeLock(); try { return action.doWith(commonCache); } finally { sl.unlockWrite(stamp); } } }
public class class_name { private <R> R doWithWriteLock(Action<K, V, R> action) { long stamp = sl.writeLock(); try { return action.doWith(commonCache); // depends on control dependency: [try], data = [none] } finally { sl.unlockWrite(stamp); } } }
public class class_name { @Override void findReferencedClassNames(final Set<String> referencedClassNames) { if (value != null) { value.findReferencedClassNames(referencedClassNames); } } }
public class class_name { @Override void findReferencedClassNames(final Set<String> referencedClassNames) { if (value != null) { value.findReferencedClassNames(referencedClassNames); // depends on control dependency: [if], data = [none] } } }
public class class_name { private final int order() { int order = count.incrementAndGet(); if ( order > Integer.MAX_VALUE - 100 ) { count.set( 0 ); } return order; } }
public class class_name { private final int order() { int order = count.incrementAndGet(); if ( order > Integer.MAX_VALUE - 100 ) { count.set( 0 ); // depends on control dependency: [if], data = [none] } return order; } }
public class class_name { public <T> void put(Class<?> type, PrefabValueFactory<T> factory) { if (type != null) { cache.put(type.getName(), factory); } } }
public class class_name { public <T> void put(Class<?> type, PrefabValueFactory<T> factory) { if (type != null) { cache.put(type.getName(), factory); // depends on control dependency: [if], data = [(type] } } }
public class class_name { private OWLClass getOWLClass(Object id) { // Special cases top and bottom if(NamedConcept.TOP.equals(id)) { return owlFactory.getOWLThing(); } else if(NamedConcept.BOTTOM.equals(id)) { return owlFactory.getOWLNothing(); } else { String iri = (String)id; return owlFactory.getOWLClass(IRI.create(iri)); } } }
public class class_name { private OWLClass getOWLClass(Object id) { // Special cases top and bottom if(NamedConcept.TOP.equals(id)) { return owlFactory.getOWLThing(); // depends on control dependency: [if], data = [none] } else if(NamedConcept.BOTTOM.equals(id)) { return owlFactory.getOWLNothing(); // depends on control dependency: [if], data = [none] } else { String iri = (String)id; return owlFactory.getOWLClass(IRI.create(iri)); // depends on control dependency: [if], data = [none] } } }
public class class_name { public void sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg) { for (IConsumer consumer : consumers) { try { consumer.onOOBControlMessage(provider, this, oobCtrlMsg); } catch (Throwable t) { log.error("exception when passing OOBCM from provider to consumers", t); } } } }
public class class_name { public void sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg) { for (IConsumer consumer : consumers) { try { consumer.onOOBControlMessage(provider, this, oobCtrlMsg); // depends on control dependency: [try], data = [none] } catch (Throwable t) { log.error("exception when passing OOBCM from provider to consumers", t); } // depends on control dependency: [catch], data = [none] } } }
public class class_name { private void findUsedByContainerAnnotations(Component component, String typeName) { try { Class<?> type = getTypeRepository().loadClass(typeName); UsedByContainer[] annotations = type.getAnnotationsByType(UsedByContainer.class); for (UsedByContainer annotation : annotations) { String name = annotation.name(); String description = annotation.description(); String technology = annotation.technology(); Container container = findContainerByNameOrCanonicalName(component, name); if (container != null) { container.uses(component, description, technology); } else { log.warn("A container named \"" + name + "\" could not be found."); } } } catch (ClassNotFoundException e) { log.warn("Could not load type " + typeName); } } }
public class class_name { private void findUsedByContainerAnnotations(Component component, String typeName) { try { Class<?> type = getTypeRepository().loadClass(typeName); UsedByContainer[] annotations = type.getAnnotationsByType(UsedByContainer.class); for (UsedByContainer annotation : annotations) { String name = annotation.name(); String description = annotation.description(); String technology = annotation.technology(); Container container = findContainerByNameOrCanonicalName(component, name); if (container != null) { container.uses(component, description, technology); // depends on control dependency: [if], data = [none] } else { log.warn("A container named \"" + name + "\" could not be found."); // depends on control dependency: [if], data = [none] } } } catch (ClassNotFoundException e) { log.warn("Could not load type " + typeName); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static Set<String> getCollateNames() { final Set<String> types = new HashSet<String>(); final Iterator<OCollateFactory> ite = getCollateFactories(); while (ite.hasNext()) { types.addAll(ite.next().getNames()); } return types; } }
public class class_name { public static Set<String> getCollateNames() { final Set<String> types = new HashSet<String>(); final Iterator<OCollateFactory> ite = getCollateFactories(); while (ite.hasNext()) { types.addAll(ite.next().getNames()); // depends on control dependency: [while], data = [none] } return types; } }
public class class_name { boolean isEscaped() { Scope hoistScope = null; for (Reference ref : references) { if (hoistScope == null) { hoistScope = ref.getScope().getClosestHoistScope(); } else if (hoistScope != ref.getScope().getClosestHoistScope()) { return true; } } return false; } }
public class class_name { boolean isEscaped() { Scope hoistScope = null; for (Reference ref : references) { if (hoistScope == null) { hoistScope = ref.getScope().getClosestHoistScope(); // depends on control dependency: [if], data = [none] } else if (hoistScope != ref.getScope().getClosestHoistScope()) { return true; // depends on control dependency: [if], data = [none] } } return false; } }
public class class_name { public void start() { if (!started.compareAndSet(false, true)) { return; } LOG.debug("Starting panel rendering and trying to open attached webcam"); starting = true; if (updater == null) { updater = new ImageUpdater(); } updater.start(); try { errored = !webcam.open(); } catch (WebcamException e) { errored = true; Display.getDefault().syncExec(new Runnable() { @Override public void run() { redraw(); } }); throw e; } finally { starting = false; } } }
public class class_name { public void start() { if (!started.compareAndSet(false, true)) { return; // depends on control dependency: [if], data = [none] } LOG.debug("Starting panel rendering and trying to open attached webcam"); starting = true; if (updater == null) { updater = new ImageUpdater(); // depends on control dependency: [if], data = [none] } updater.start(); try { errored = !webcam.open(); // depends on control dependency: [try], data = [none] } catch (WebcamException e) { errored = true; Display.getDefault().syncExec(new Runnable() { @Override public void run() { redraw(); } }); throw e; } finally { // depends on control dependency: [catch], data = [none] starting = false; } } }
public class class_name { public AwsSecurityFindingFilters withRecommendationText(StringFilter... recommendationText) { if (this.recommendationText == null) { setRecommendationText(new java.util.ArrayList<StringFilter>(recommendationText.length)); } for (StringFilter ele : recommendationText) { this.recommendationText.add(ele); } return this; } }
public class class_name { public AwsSecurityFindingFilters withRecommendationText(StringFilter... recommendationText) { if (this.recommendationText == null) { setRecommendationText(new java.util.ArrayList<StringFilter>(recommendationText.length)); // depends on control dependency: [if], data = [none] } for (StringFilter ele : recommendationText) { this.recommendationText.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { @Override public final String getAsString(final FacesContext context, final UIComponent component, final Object value) { if (value == null) { return ""; } if (value instanceof String) { return (String) value; } if (context == null || component == null) { throw new NullPointerException(); } try { String pattern = (String) component.getAttributes() .get(TieConstants.WIDGET_ATTR_PATTERN); SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, getLocale(context, component)); return dateFormat.format(value); } catch (Exception e) { throw new ConverterException(e); } } }
public class class_name { @Override public final String getAsString(final FacesContext context, final UIComponent component, final Object value) { if (value == null) { return ""; // depends on control dependency: [if], data = [none] } if (value instanceof String) { return (String) value; // depends on control dependency: [if], data = [none] } if (context == null || component == null) { throw new NullPointerException(); } try { String pattern = (String) component.getAttributes() .get(TieConstants.WIDGET_ATTR_PATTERN); SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, getLocale(context, component)); return dateFormat.format(value); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new ConverterException(e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static List<ImageFormat> getDefaultFormats() { if (sAllDefaultFormats == null) { List<ImageFormat> mDefaultFormats = new ArrayList<>(9); mDefaultFormats.add(JPEG); mDefaultFormats.add(PNG); mDefaultFormats.add(GIF); mDefaultFormats.add(BMP); mDefaultFormats.add(ICO); mDefaultFormats.add(WEBP_SIMPLE); mDefaultFormats.add(WEBP_LOSSLESS); mDefaultFormats.add(WEBP_EXTENDED); mDefaultFormats.add(WEBP_EXTENDED_WITH_ALPHA); mDefaultFormats.add(WEBP_ANIMATED); mDefaultFormats.add(HEIF); sAllDefaultFormats = ImmutableList.copyOf(mDefaultFormats); } return sAllDefaultFormats; } }
public class class_name { public static List<ImageFormat> getDefaultFormats() { if (sAllDefaultFormats == null) { List<ImageFormat> mDefaultFormats = new ArrayList<>(9); mDefaultFormats.add(JPEG); // depends on control dependency: [if], data = [none] mDefaultFormats.add(PNG); // depends on control dependency: [if], data = [none] mDefaultFormats.add(GIF); // depends on control dependency: [if], data = [none] mDefaultFormats.add(BMP); // depends on control dependency: [if], data = [none] mDefaultFormats.add(ICO); // depends on control dependency: [if], data = [none] mDefaultFormats.add(WEBP_SIMPLE); // depends on control dependency: [if], data = [none] mDefaultFormats.add(WEBP_LOSSLESS); // depends on control dependency: [if], data = [none] mDefaultFormats.add(WEBP_EXTENDED); // depends on control dependency: [if], data = [none] mDefaultFormats.add(WEBP_EXTENDED_WITH_ALPHA); // depends on control dependency: [if], data = [none] mDefaultFormats.add(WEBP_ANIMATED); // depends on control dependency: [if], data = [none] mDefaultFormats.add(HEIF); // depends on control dependency: [if], data = [none] sAllDefaultFormats = ImmutableList.copyOf(mDefaultFormats); // depends on control dependency: [if], data = [none] } return sAllDefaultFormats; } }
public class class_name { protected double updateEvaluationWindow(int index,int val){ int[] newEnsembleWindows = new int[this.ensembleWindows[index].length]; int wsize = (int)Math.min(this.evaluationSizeOption.getValue(),this.ensembleAges[index]+1); int sum = 0; for (int i = 0; i < wsize-1 ; i++){ newEnsembleWindows[i+1] = this.ensembleWindows[index][i]; sum = sum + this.ensembleWindows[index][i]; } newEnsembleWindows[0] = val; this.ensembleWindows[index] = newEnsembleWindows; if (this.ensembleAges[index] >= this.maturityOption.getValue()) return (sum + val) * 1.0/wsize; else return 0; } }
public class class_name { protected double updateEvaluationWindow(int index,int val){ int[] newEnsembleWindows = new int[this.ensembleWindows[index].length]; int wsize = (int)Math.min(this.evaluationSizeOption.getValue(),this.ensembleAges[index]+1); int sum = 0; for (int i = 0; i < wsize-1 ; i++){ newEnsembleWindows[i+1] = this.ensembleWindows[index][i]; // depends on control dependency: [for], data = [i] sum = sum + this.ensembleWindows[index][i]; // depends on control dependency: [for], data = [i] } newEnsembleWindows[0] = val; this.ensembleWindows[index] = newEnsembleWindows; if (this.ensembleAges[index] >= this.maturityOption.getValue()) return (sum + val) * 1.0/wsize; else return 0; } }
public class class_name { public double[] getConfidenceInterval(final double alpha, final Map<?, Double> metricValuesPerDimension) { SummaryStatistics differences = new SummaryStatistics(); for (Double d : metricValuesPerDimension.values()) { differences.addValue(d); } return getConfidenceInterval(alpha, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean()); } }
public class class_name { public double[] getConfidenceInterval(final double alpha, final Map<?, Double> metricValuesPerDimension) { SummaryStatistics differences = new SummaryStatistics(); for (Double d : metricValuesPerDimension.values()) { differences.addValue(d); // depends on control dependency: [for], data = [d] } return getConfidenceInterval(alpha, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean()); } }
public class class_name { private void overlapViews(int width) { if (width == mWidth) { return; } //remember this width so it is't processed twice mWidth = width; float percentage = calculatePercentage(width); float alpha = percentage / 100; mSmallView.setAlpha(1); mSmallView.setClickable(false); mLargeView.bringToFront(); mLargeView.setAlpha(alpha); mLargeView.setClickable(true); mLargeView.setVisibility(alpha > 0.01f ? View.VISIBLE : View.GONE); //notify the crossfadeListener if (mCrossfadeListener != null) { mCrossfadeListener.onCrossfade(mContainer, calculatePercentage(width), width); } } }
public class class_name { private void overlapViews(int width) { if (width == mWidth) { return; // depends on control dependency: [if], data = [none] } //remember this width so it is't processed twice mWidth = width; float percentage = calculatePercentage(width); float alpha = percentage / 100; mSmallView.setAlpha(1); mSmallView.setClickable(false); mLargeView.bringToFront(); mLargeView.setAlpha(alpha); mLargeView.setClickable(true); mLargeView.setVisibility(alpha > 0.01f ? View.VISIBLE : View.GONE); //notify the crossfadeListener if (mCrossfadeListener != null) { mCrossfadeListener.onCrossfade(mContainer, calculatePercentage(width), width); // depends on control dependency: [if], data = [none] } } }
public class class_name { @Override public String getValueAsString() { Set<String> selected = getValue(); if (selected == null || selected.isEmpty()) { return null; } StringBuilder stringValues = new StringBuilder(); boolean first = true; for (String item : selected) { if (!first) { stringValues.append(", "); } stringValues.append(item); first = false; } return stringValues.toString(); } }
public class class_name { @Override public String getValueAsString() { Set<String> selected = getValue(); if (selected == null || selected.isEmpty()) { return null; // depends on control dependency: [if], data = [none] } StringBuilder stringValues = new StringBuilder(); boolean first = true; for (String item : selected) { if (!first) { stringValues.append(", "); // depends on control dependency: [if], data = [none] } stringValues.append(item); // depends on control dependency: [for], data = [item] first = false; // depends on control dependency: [for], data = [none] } return stringValues.toString(); } }
public class class_name { public void setTriggers(java.util.Collection<Trigger> triggers) { if (triggers == null) { this.triggers = null; return; } this.triggers = new java.util.ArrayList<Trigger>(triggers); } }
public class class_name { public void setTriggers(java.util.Collection<Trigger> triggers) { if (triggers == null) { this.triggers = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.triggers = new java.util.ArrayList<Trigger>(triggers); } }
public class class_name { private void esDelete(String index, String id) { logger.debug("Deleting {}/{}", index, id); if (!closed) { esClient.delete(index, id); } else { logger.warn("trying to remove a file while closing crawler. Document [{}]/[{}] has been ignored", index, id); } } }
public class class_name { private void esDelete(String index, String id) { logger.debug("Deleting {}/{}", index, id); if (!closed) { esClient.delete(index, id); // depends on control dependency: [if], data = [none] } else { logger.warn("trying to remove a file while closing crawler. Document [{}]/[{}] has been ignored", index, id); // depends on control dependency: [if], data = [none] } } }
public class class_name { public long writeLogTo(long start, Writer w) throws IOException { CountingOutputStream os = new CountingOutputStream(new WriterOutputStream(w)); try (Session f = source.open()) { f.skip(start); if (completed) { // write everything till EOF byte[] buf = new byte[1024]; int sz; while ((sz = f.read(buf)) >= 0) os.write(buf, 0, sz); } else { ByteBuf buf = new ByteBuf(null, f); HeadMark head = new HeadMark(buf); TailMark tail = new TailMark(buf); while (tail.moveToNextLine(f)) { head.moveTo(tail, os); } head.finish(os); } } os.flush(); return os.getCount()+start; } }
public class class_name { public long writeLogTo(long start, Writer w) throws IOException { CountingOutputStream os = new CountingOutputStream(new WriterOutputStream(w)); try (Session f = source.open()) { f.skip(start); if (completed) { // write everything till EOF byte[] buf = new byte[1024]; int sz; while ((sz = f.read(buf)) >= 0) os.write(buf, 0, sz); } else { ByteBuf buf = new ByteBuf(null, f); HeadMark head = new HeadMark(buf); TailMark tail = new TailMark(buf); while (tail.moveToNextLine(f)) { head.moveTo(tail, os); // depends on control dependency: [while], data = [none] } head.finish(os); } } os.flush(); return os.getCount()+start; } }
public class class_name { @Override public String getChangedProperties(WebAppSecurityConfig original) { // Bail out if it is the same object, or if this isn't of the right type. if (this == original) { return ""; } if (!(original instanceof WebAppSecurityConfigImpl)) { return ""; } StringBuffer buf = new StringBuffer(); WebAppSecurityConfigImpl orig = (WebAppSecurityConfigImpl) original; for (Entry<String, String> entry : configAttributes.entrySet()) { try { Field field = (WebAppSecurityConfigImpl.class).getDeclaredField(entry.getValue()); field.setAccessible(true); appendToBufferIfDifferent(buf, entry.getKey(), field.get(this), field.get(orig)); } catch (Exception e) { // this won't happen. just ignore. if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Exception is caught " + e); } } } return buf.toString(); } }
public class class_name { @Override public String getChangedProperties(WebAppSecurityConfig original) { // Bail out if it is the same object, or if this isn't of the right type. if (this == original) { return ""; // depends on control dependency: [if], data = [none] } if (!(original instanceof WebAppSecurityConfigImpl)) { return ""; // depends on control dependency: [if], data = [none] } StringBuffer buf = new StringBuffer(); WebAppSecurityConfigImpl orig = (WebAppSecurityConfigImpl) original; for (Entry<String, String> entry : configAttributes.entrySet()) { try { Field field = (WebAppSecurityConfigImpl.class).getDeclaredField(entry.getValue()); field.setAccessible(true); // depends on control dependency: [try], data = [none] appendToBufferIfDifferent(buf, entry.getKey(), field.get(this), field.get(orig)); // depends on control dependency: [try], data = [none] } catch (Exception e) { // this won't happen. just ignore. if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Exception is caught " + e); // depends on control dependency: [if], data = [none] } } // depends on control dependency: [catch], data = [none] } return buf.toString(); } }
public class class_name { @Override public void printStackTrace(java.io.PrintWriter pw) { synchronized (pw) { if (detail != null) { detail.printStackTrace(pw); } super.printStackTrace(pw); } } }
public class class_name { @Override public void printStackTrace(java.io.PrintWriter pw) { synchronized (pw) { if (detail != null) { detail.printStackTrace(pw); // depends on control dependency: [if], data = [none] } super.printStackTrace(pw); } } }
public class class_name { public ConfigParams getSection(String section) { ConfigParams result = new ConfigParams(); String prefix = section + "."; for (Map.Entry<String, String> entry : this.entrySet()) { String key = entry.getKey(); // Prevents exception on the next line if (key.length() < prefix.length()) continue; // Perform case sensitive match String keyPrefix = key.substring(0, prefix.length()); if (keyPrefix.equalsIgnoreCase(prefix)) { key = key.substring(prefix.length()); result.put(key, entry.getValue()); } } return result; } }
public class class_name { public ConfigParams getSection(String section) { ConfigParams result = new ConfigParams(); String prefix = section + "."; for (Map.Entry<String, String> entry : this.entrySet()) { String key = entry.getKey(); // Prevents exception on the next line if (key.length() < prefix.length()) continue; // Perform case sensitive match String keyPrefix = key.substring(0, prefix.length()); if (keyPrefix.equalsIgnoreCase(prefix)) { key = key.substring(prefix.length()); // depends on control dependency: [if], data = [none] result.put(key, entry.getValue()); // depends on control dependency: [if], data = [none] } } return result; } }
public class class_name { public CloneStackRequest withCloneAppIds(String... cloneAppIds) { if (this.cloneAppIds == null) { setCloneAppIds(new com.amazonaws.internal.SdkInternalList<String>(cloneAppIds.length)); } for (String ele : cloneAppIds) { this.cloneAppIds.add(ele); } return this; } }
public class class_name { public CloneStackRequest withCloneAppIds(String... cloneAppIds) { if (this.cloneAppIds == null) { setCloneAppIds(new com.amazonaws.internal.SdkInternalList<String>(cloneAppIds.length)); // depends on control dependency: [if], data = [none] } for (String ele : cloneAppIds) { this.cloneAppIds.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { public char[] allocSmallCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getSmallCBuffer(minSize); if (result != null) { return result; } } // Nope; no recycler, or it has no suitable buffers, let's create: return new char[minSize]; } }
public class class_name { public char[] allocSmallCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getSmallCBuffer(minSize); if (result != null) { return result; // depends on control dependency: [if], data = [none] } } // Nope; no recycler, or it has no suitable buffers, let's create: return new char[minSize]; } }
public class class_name { public int write(byte[] buf, int size) { if (mOpenStream == null || !(mOpenStream instanceof WritableByteChannel)) return -1; try { WritableByteChannel channel = (WritableByteChannel) mOpenStream; ByteBuffer buffer = ByteBuffer.allocate(size); buffer.put(buf, 0, size); buffer.flip(); return channel.write(buffer); } catch (IOException e) { log.error("Got error writing to file: {}; {}", mOpenStream, e); return -1; } } }
public class class_name { public int write(byte[] buf, int size) { if (mOpenStream == null || !(mOpenStream instanceof WritableByteChannel)) return -1; try { WritableByteChannel channel = (WritableByteChannel) mOpenStream; ByteBuffer buffer = ByteBuffer.allocate(size); buffer.put(buf, 0, size); // depends on control dependency: [try], data = [none] buffer.flip(); // depends on control dependency: [try], data = [none] return channel.write(buffer); // depends on control dependency: [try], data = [none] } catch (IOException e) { log.error("Got error writing to file: {}; {}", mOpenStream, e); return -1; } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static List<IdRange> parseRangeSequence(String idRangeSequence) { StringTokenizer tokenizer = new StringTokenizer(idRangeSequence, " "); List<IdRange> ranges = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { ranges.add(parseRange(tokenizer.nextToken())); } return ranges; } }
public class class_name { public static List<IdRange> parseRangeSequence(String idRangeSequence) { StringTokenizer tokenizer = new StringTokenizer(idRangeSequence, " "); List<IdRange> ranges = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { ranges.add(parseRange(tokenizer.nextToken())); // depends on control dependency: [while], data = [none] } return ranges; } }
public class class_name { void addAggregateIndexes(Document doc) { Document old=aggregateIndexes.put(doc.get(FieldNames.UUID), doc); if (old != null) { Util.disposeDocument(old); } } }
public class class_name { void addAggregateIndexes(Document doc) { Document old=aggregateIndexes.put(doc.get(FieldNames.UUID), doc); if (old != null) { Util.disposeDocument(old); // depends on control dependency: [if], data = [(old] } } }
public class class_name { protected void removeDestinationListener(DestinationListener destinationListener) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeDestinationListener", new Object[] { destinationListener }); synchronized (this) { for (int i = 0; i < destinationListeners.size(); i++) { DestinationListenerDataObject listenerDataObject = destinationListeners.get(i); if (destinationListener.equals(listenerDataObject.getDestinationLister())) { destinationListeners.remove(listenerDataObject); } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeDestinationListener"); } }
public class class_name { protected void removeDestinationListener(DestinationListener destinationListener) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeDestinationListener", new Object[] { destinationListener }); synchronized (this) { for (int i = 0; i < destinationListeners.size(); i++) { DestinationListenerDataObject listenerDataObject = destinationListeners.get(i); if (destinationListener.equals(listenerDataObject.getDestinationLister())) { destinationListeners.remove(listenerDataObject); // depends on control dependency: [if], data = [none] } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeDestinationListener"); } }
public class class_name { private void optimize(NavPath path) { int pt = 0; while (pt < path.length()-2) { float sx = path.getX(pt); float sy = path.getY(pt); float nx = path.getX(pt+2); float ny = path.getY(pt+2); if (isClear(sx,sy,nx,ny,0.1f)) { path.remove(pt+1); } else { pt++; } } } }
public class class_name { private void optimize(NavPath path) { int pt = 0; while (pt < path.length()-2) { float sx = path.getX(pt); float sy = path.getY(pt); float nx = path.getX(pt+2); float ny = path.getY(pt+2); if (isClear(sx,sy,nx,ny,0.1f)) { path.remove(pt+1); // depends on control dependency: [if], data = [none] } else { pt++; // depends on control dependency: [if], data = [none] } } } }
public class class_name { private double checkScore() { int i, j, op, s; double sco; sco = 0; op = 0; s = 0; i = B1; j = B2; while (i <= E1 && j <= E2) { op = sapp0[s ++]; if (op == 0) { sco += sij[i - 1][j - 1]; //if (debug) //System.err.println(String.format("%d-%d %f\n", i - 1, j - 1, sij[i - 1][j - 1])); i ++; j ++; } else if (op > 0) { sco -= g+op*h; j = j+op; } else { sco -= g-op*h; i = i-op; } } return(sco); } }
public class class_name { private double checkScore() { int i, j, op, s; double sco; sco = 0; op = 0; s = 0; i = B1; j = B2; while (i <= E1 && j <= E2) { op = sapp0[s ++]; // depends on control dependency: [while], data = [none] if (op == 0) { sco += sij[i - 1][j - 1]; // depends on control dependency: [if], data = [none] //if (debug) //System.err.println(String.format("%d-%d %f\n", i - 1, j - 1, sij[i - 1][j - 1])); i ++; // depends on control dependency: [if], data = [none] j ++; // depends on control dependency: [if], data = [none] } else if (op > 0) { sco -= g+op*h; // depends on control dependency: [if], data = [none] j = j+op; // depends on control dependency: [if], data = [none] } else { sco -= g-op*h; // depends on control dependency: [if], data = [none] i = i-op; // depends on control dependency: [if], data = [none] } } return(sco); } }
public class class_name { public MonetaryAmount parse(CharSequence text) throws MonetaryParseException { ParseContext ctx = new ParseContext(text); try { for (FormatToken token : this.positiveTokens) { token.parse(ctx); } } catch (Exception e) { // try parsing negative... Logger log = Logger.getLogger(getClass().getName()); if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, "Failed to parse positive pattern, trying negative for: " + text, e); } for (FormatToken token : this.negativeTokens) { token.parse(ctx); } } CurrencyUnit unit = ctx.getParsedCurrency(); Number num = ctx.getParsedNumber(); if (unit==null) { unit = this.amountFormatContext.get(CurrencyUnit.class); } if (num==null) { throw new MonetaryParseException(text.toString(), -1); } MonetaryAmountFactory<?> factory = this.amountFormatContext.getParseFactory(); if (factory == null) { factory = Monetary.getDefaultAmountFactory(); } return factory.setCurrency(unit).setNumber(num).create(); } }
public class class_name { public MonetaryAmount parse(CharSequence text) throws MonetaryParseException { ParseContext ctx = new ParseContext(text); try { for (FormatToken token : this.positiveTokens) { token.parse(ctx); // depends on control dependency: [for], data = [token] } } catch (Exception e) { // try parsing negative... Logger log = Logger.getLogger(getClass().getName()); if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, "Failed to parse positive pattern, trying negative for: " + text, e); // depends on control dependency: [if], data = [none] } for (FormatToken token : this.negativeTokens) { token.parse(ctx); // depends on control dependency: [for], data = [token] } } CurrencyUnit unit = ctx.getParsedCurrency(); Number num = ctx.getParsedNumber(); if (unit==null) { unit = this.amountFormatContext.get(CurrencyUnit.class); } if (num==null) { throw new MonetaryParseException(text.toString(), -1); } MonetaryAmountFactory<?> factory = this.amountFormatContext.getParseFactory(); if (factory == null) { factory = Monetary.getDefaultAmountFactory(); } return factory.setCurrency(unit).setNumber(num).create(); } }
public class class_name { public static void indexDir(final Indexer indexer, final List<File> knownFiles, final File dir) { final List<File> classes = Utils4J.pathsFiles(dir.getPath(), Utils4J::classFile); for (final File file : classes) { indexClassFile(indexer, knownFiles, file); } } }
public class class_name { public static void indexDir(final Indexer indexer, final List<File> knownFiles, final File dir) { final List<File> classes = Utils4J.pathsFiles(dir.getPath(), Utils4J::classFile); for (final File file : classes) { indexClassFile(indexer, knownFiles, file); // depends on control dependency: [for], data = [file] } } }
public class class_name { public void setDestinations(java.util.Collection<InputDestinationRequest> destinations) { if (destinations == null) { this.destinations = null; return; } this.destinations = new java.util.ArrayList<InputDestinationRequest>(destinations); } }
public class class_name { public void setDestinations(java.util.Collection<InputDestinationRequest> destinations) { if (destinations == null) { this.destinations = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.destinations = new java.util.ArrayList<InputDestinationRequest>(destinations); } }
public class class_name { public void addErrorMsgs(final Set<String> msgs) { if (msgs != null) { this._errorMsgs.addAll(msgs); if (!msgs.isEmpty()) { this._status = ValidationStatus.ERROR; } } } }
public class class_name { public void addErrorMsgs(final Set<String> msgs) { if (msgs != null) { this._errorMsgs.addAll(msgs); // depends on control dependency: [if], data = [(msgs] if (!msgs.isEmpty()) { this._status = ValidationStatus.ERROR; // depends on control dependency: [if], data = [none] } } } }
public class class_name { private static TransitionType getTransition(TransitionType a, TransitionType b, int ox, int oy) { final TransitionType type = getTransitionHorizontalVertical(a, b, ox, oy); if (type != null) { return type; } return getTransitionDiagonals(a, b, ox, oy); } }
public class class_name { private static TransitionType getTransition(TransitionType a, TransitionType b, int ox, int oy) { final TransitionType type = getTransitionHorizontalVertical(a, b, ox, oy); if (type != null) { return type; // depends on control dependency: [if], data = [none] } return getTransitionDiagonals(a, b, ox, oy); } }
public class class_name { public static ConceptId getInstance(String id, Metadata metadata) { List<Object> key = new ArrayList<>(1); key.add(id); ConceptId result = metadata.getFromConceptIdCache(key); if (result != null) { return result; } else { result = new SimpleConceptId(id, metadata); metadata.putInConceptIdCache(key, result); return result; } } }
public class class_name { public static ConceptId getInstance(String id, Metadata metadata) { List<Object> key = new ArrayList<>(1); key.add(id); ConceptId result = metadata.getFromConceptIdCache(key); if (result != null) { return result; // depends on control dependency: [if], data = [none] } else { result = new SimpleConceptId(id, metadata); // depends on control dependency: [if], data = [none] metadata.putInConceptIdCache(key, result); // depends on control dependency: [if], data = [none] return result; // depends on control dependency: [if], data = [none] } } }
public class class_name { public void putAllValues(Map<String, V> input) { for (Map.Entry<String, V> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } } }
public class class_name { public void putAllValues(Map<String, V> input) { for (Map.Entry<String, V> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); // depends on control dependency: [for], data = [entry] } } }
public class class_name { public void marshall(AppliedTerminology appliedTerminology, ProtocolMarshaller protocolMarshaller) { if (appliedTerminology == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(appliedTerminology.getName(), NAME_BINDING); protocolMarshaller.marshall(appliedTerminology.getTerms(), TERMS_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(AppliedTerminology appliedTerminology, ProtocolMarshaller protocolMarshaller) { if (appliedTerminology == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(appliedTerminology.getName(), NAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(appliedTerminology.getTerms(), TERMS_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 { @SuppressWarnings("checkstyle:all") protected void generateAbstractBuilder() { final TypeReference abstractBuilder = getAbstractBuilderImpl(); final TypeReference expressionBuilder = getExpressionBuilderImpl(); StringConcatenationClient content = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("/** Abstract implementation of a builder for the " //$NON-NLS-1$ + getLanguageName() + " language."); //$NON-NLS-1$ it.newLine(); it.append(" */"); //$NON-NLS-1$ it.newLine(); it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$ it.newLine(); it.append("public abstract class "); //$NON-NLS-1$ it.append(abstractBuilder.getSimpleName()); it.append(" {"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\t\tprivate "); //$NON-NLS-1$ it.append(IQualifiedNameProvider.class); it.append(" qualifiedNameProvider;"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(JvmModelAssociator.class); it.append(" associations;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(CommonTypeComputationServices.class); it.append(" services;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(ImportManager.class); it.append(" importManager;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeReferences;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(Primitives.class); it.append(" primitives;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IImportsConfiguration.class); it.append(" importsConfiguration;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IResourceFactory.class); it.append(" resourceFactory;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate String fileExtension;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" typeResolutionContext;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tpublic void setFileExtensions(@"); //$NON-NLS-1$ it.append(Named.class); it.append("("); //$NON-NLS-1$ it.append(Constants.class); it.append(".FILE_EXTENSIONS) String fileExtensions) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthis.fileExtension = fileExtensions.split(\"[:;,]+\")[0];"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected <T> T getAssociatedElement(Class<T> expectedType, "); //$NON-NLS-1$ it.append(EObject.class); it.append(" dslObject, "); //$NON-NLS-1$ it.append(Resource.class); it.append(" resource) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (final "); //$NON-NLS-1$ it.append(EObject.class); it.append(" obj : this.associations.getJvmElements(dslObject)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (expectedType.isInstance(obj)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\treturn expectedType.cast(obj);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (resource instanceof "); //$NON-NLS-1$ it.append(DerivedStateAwareResource.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t(("); //$NON-NLS-1$ it.append(DerivedStateAwareResource.class); it.append(") resource).discardDerivedState();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tresource.getContents();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn getAssociatedElement(expectedType, dslObject, null);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthrow new "); //$NON-NLS-1$ it.append(IllegalStateException.class); it.append("(\"No JvmFormalParameter associated to \" + dslObject + \" in \" + dslObject.eContainer());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected void setTypeResolutionContext("); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" context) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthis.typeResolutionContext = context;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" getTypeResolutionContext() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.typeResolutionContext;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the script's file extension."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tpublic String getScriptFileExtension() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.fileExtension;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the builder of type references."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the type reference builder."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" getTypeReferences() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.typeReferences;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the primitive type tools."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the primitive type tools."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(Primitives.class); it.append(" getPrimitiveTypes() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.primitives;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" innerFindType("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" provider = getTypeResolutionContext();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(JvmType.class); it.append(" type = null;"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (provider != null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttype = provider.findTypeByName(typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeRefs = getTypeReferences();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (type == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttype = typeRefs.findDeclaredType(typeName, context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (type == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn null;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn typeRefs.createTypeRef(type);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" findType("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" type = innerFindType(context, typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (!isTypeReference(type)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(XtextResource.class); it.append(" xtextResource = toResource(context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tfor (String packageName : getImportsConfiguration().getImplicitlyImportedPackages(xtextResource)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t"); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference = innerFindType(context, packageName + \".\" + typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tif (isTypeReference(typeReference)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t\treturn typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tthrow new "); //$NON-NLS-1$ it.append(TypeNotPresentException.class); it.append("(typeName, null);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn type;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected static "); //$NON-NLS-1$ it.append(XtextResource.class); it.append(" toResource("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn ("); //$NON-NLS-1$ it.append(XtextResource.class); it.append(") (context instanceof "); //$NON-NLS-1$ it.append(Resource.class); it.append(" ? context : (("); //$NON-NLS-1$ it.append(EObject.class); it.append(")context).eResource());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the type reference for the given name in the given context."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" newTypeRef(String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn newTypeRef(eResource(), typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the type reference for the given name in the given context."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" newTypeRef("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\ttry {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttypeReference = findType(context, typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tgetImportManager().addImportFor(typeReference.getType());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn ("); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(") typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t} catch ("); //$NON-NLS-1$ it.append(TypeNotPresentException.class); it.append(" exception) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" pref = "); //$NON-NLS-1$ it.append(expressionBuilder); it.append(".parseType(context, typeName, this);"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" baseType = findType(context, pref.getType().getIdentifier());"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal int len = pref.getArguments().size();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append("[] args = new "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append("[len];"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (int i = 0; i < len; ++i) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" original = pref.getArguments().get(i);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (original instanceof "); //$NON-NLS-1$ it.append(JvmAnyTypeReference.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = "); //$NON-NLS-1$ it.append(EcoreUtil.class); it.append(".copy(original);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t} else if (original instanceof "); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tfinal "); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(" wc = EcoreUtil.copy(("); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(") original);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tfor (final "); //$NON-NLS-1$ it.append(JvmTypeConstraint.class); it.append(" c : wc.getConstraints()) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t\tc.setTypeReference(newTypeRef(context, c.getTypeReference().getIdentifier()));"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = wc;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t} else {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = newTypeRef(context, original.getIdentifier());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeRefs = getTypeReferences();"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn typeRefs.createTypeRef(baseType.getType(), args);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the first parameter is a subtype of the second parameter."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @param context the context."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param subType the subtype to test."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param superType the expected super type."); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the type reference."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isSubTypeOf("); //$NON-NLS-1$ it.append(EObject.class); it.append(" context, "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" subType, "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" superType) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (isTypeReference(superType) && isTypeReference(subType)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(StandardTypeReferenceOwner.class); it.append(" owner = new "); //$NON-NLS-1$ it.append(StandardTypeReferenceOwner.class); it.append("(services, context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(LightweightTypeReferenceFactory.class); it.append(" factory = new "); //$NON-NLS-1$ it.append(LightweightTypeReferenceFactory.class); it.append("(owner, false);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(LightweightTypeReference.class); it.append(" reference = factory.toLightweightReference(subType);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn reference.isSubtypeOf(superType.getType());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn false;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the given object is a valid type reference."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isTypeReference("); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn (typeReference != null && !typeReference.eIsProxy()"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t&& typeReference.getType() != null && !typeReference.getType().eIsProxy());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the import's configuration."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the import's configuration."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(IImportsConfiguration.class); it.append(" getImportsConfiguration() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.importsConfiguration;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Compute a unused URI for a synthetic resource."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param resourceSet the resource set in which the resource should be located."); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the uri."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(URI.class); it.append(" computeUnusedUri("); //$NON-NLS-1$ it.append(ResourceSet.class); it.append(" resourceSet) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tString name = \"__synthetic\";"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (int i = 0; i < Integer.MAX_VALUE; ++i) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(URI.class); it.append(" syntheticUri = "); //$NON-NLS-1$ it.append(URI.class); it.append(".createURI(name + i + \".\" + getScriptFileExtension());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (resourceSet.getResource(syntheticUri, false) == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\treturn syntheticUri;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthrow new IllegalStateException();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the resource factory."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the resource factory."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(IResourceFactory.class); it.append(" getResourceFactory() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.resourceFactory;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the type could contains functions with a body."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isActionBodyAllowed("); //$NON-NLS-1$ it.append(getCodeElementExtractor().getLanguageTopElementType()); it.append(" type) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn "); //$NON-NLS-1$ if (getCodeBuilderConfig().getNoActionBodyTypes().isEmpty()) { it.append("true"); //$NON-NLS-1$ } else { it.append("!("); //$NON-NLS-1$ boolean first = true; for (String noBodyType : getCodeBuilderConfig().getNoActionBodyTypes()) { if (first) { first = false; } else { it.newLine(); it.append("\t\t\t|| "); //$NON-NLS-1$ } it.append("type instanceof "); //$NON-NLS-1$ it.append(new TypeReference(getCodeElementExtractor().getLanguageBasePackage() + "." + noBodyType)); //$NON-NLS-1$ } it.append(")"); //$NON-NLS-1$ } it.append(";"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the import manager that stores the imported types."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the import manager."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(ImportManager.class); it.append(" getImportManager() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.importManager;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected String getQualifiedName("); //$NON-NLS-1$ it.append(EObject.class); it.append(" object) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.qualifiedNameProvider.getFullyQualifiedName(object).toString();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tpublic abstract "); //$NON-NLS-1$ it.append(Resource.class); it.append(" eResource();"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tpublic void dispose() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(Resource.class); it.append(" resource = eResource();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(ResourceSet.class); it.append(" resourceSet = resource.getResourceSet();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tresourceSet.getResources().remove(resource);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(abstractBuilder, content); javaFile.writeTo(getSrcGen()); } }
public class class_name { @SuppressWarnings("checkstyle:all") protected void generateAbstractBuilder() { final TypeReference abstractBuilder = getAbstractBuilderImpl(); final TypeReference expressionBuilder = getExpressionBuilderImpl(); StringConcatenationClient content = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("/** Abstract implementation of a builder for the " //$NON-NLS-1$ + getLanguageName() + " language."); //$NON-NLS-1$ it.newLine(); it.append(" */"); //$NON-NLS-1$ it.newLine(); it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$ it.newLine(); it.append("public abstract class "); //$NON-NLS-1$ it.append(abstractBuilder.getSimpleName()); it.append(" {"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\t\tprivate "); //$NON-NLS-1$ it.append(IQualifiedNameProvider.class); it.append(" qualifiedNameProvider;"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(JvmModelAssociator.class); it.append(" associations;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(CommonTypeComputationServices.class); it.append(" services;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(ImportManager.class); it.append(" importManager;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeReferences;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(Primitives.class); it.append(" primitives;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IImportsConfiguration.class); it.append(" importsConfiguration;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IResourceFactory.class); it.append(" resourceFactory;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate String fileExtension;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" typeResolutionContext;"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Inject.class); it.newLine(); it.append("\tpublic void setFileExtensions(@"); //$NON-NLS-1$ it.append(Named.class); it.append("("); //$NON-NLS-1$ it.append(Constants.class); it.append(".FILE_EXTENSIONS) String fileExtensions) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthis.fileExtension = fileExtensions.split(\"[:;,]+\")[0];"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected <T> T getAssociatedElement(Class<T> expectedType, "); //$NON-NLS-1$ it.append(EObject.class); it.append(" dslObject, "); //$NON-NLS-1$ it.append(Resource.class); it.append(" resource) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (final "); //$NON-NLS-1$ it.append(EObject.class); it.append(" obj : this.associations.getJvmElements(dslObject)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (expectedType.isInstance(obj)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\treturn expectedType.cast(obj);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (resource instanceof "); //$NON-NLS-1$ it.append(DerivedStateAwareResource.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t(("); //$NON-NLS-1$ it.append(DerivedStateAwareResource.class); it.append(") resource).discardDerivedState();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tresource.getContents();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn getAssociatedElement(expectedType, dslObject, null);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthrow new "); //$NON-NLS-1$ it.append(IllegalStateException.class); it.append("(\"No JvmFormalParameter associated to \" + dslObject + \" in \" + dslObject.eContainer());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected void setTypeResolutionContext("); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" context) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthis.typeResolutionContext = context;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" getTypeResolutionContext() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.typeResolutionContext;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the script's file extension."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tpublic String getScriptFileExtension() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.fileExtension;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the builder of type references."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the type reference builder."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" getTypeReferences() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.typeReferences;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the primitive type tools."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the primitive type tools."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(Primitives.class); it.append(" getPrimitiveTypes() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.primitives;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprivate "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" innerFindType("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(IJvmTypeProvider.class); it.append(" provider = getTypeResolutionContext();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(JvmType.class); it.append(" type = null;"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (provider != null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttype = provider.findTypeByName(typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeRefs = getTypeReferences();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (type == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttype = typeRefs.findDeclaredType(typeName, context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (type == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn null;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn typeRefs.createTypeRef(type);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" findType("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" type = innerFindType(context, typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (!isTypeReference(type)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(XtextResource.class); it.append(" xtextResource = toResource(context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tfor (String packageName : getImportsConfiguration().getImplicitlyImportedPackages(xtextResource)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t"); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference = innerFindType(context, packageName + \".\" + typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tif (isTypeReference(typeReference)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t\treturn typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tthrow new "); //$NON-NLS-1$ it.append(TypeNotPresentException.class); it.append("(typeName, null);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn type;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected static "); //$NON-NLS-1$ it.append(XtextResource.class); it.append(" toResource("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn ("); //$NON-NLS-1$ it.append(XtextResource.class); it.append(") (context instanceof "); //$NON-NLS-1$ it.append(Resource.class); it.append(" ? context : (("); //$NON-NLS-1$ it.append(EObject.class); it.append(")context).eResource());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the type reference for the given name in the given context."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" newTypeRef(String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn newTypeRef(eResource(), typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the type reference for the given name in the given context."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" newTypeRef("); //$NON-NLS-1$ it.append(Notifier.class); it.append(" context, String typeName) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\ttry {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\ttypeReference = findType(context, typeName);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tgetImportManager().addImportFor(typeReference.getType());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn ("); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(") typeReference;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t} catch ("); //$NON-NLS-1$ it.append(TypeNotPresentException.class); it.append(" exception) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmParameterizedTypeReference.class); it.append(" pref = "); //$NON-NLS-1$ it.append(expressionBuilder); it.append(".parseType(context, typeName, this);"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" baseType = findType(context, pref.getType().getIdentifier());"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal int len = pref.getArguments().size();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append("[] args = new "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append("[len];"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (int i = 0; i < len; ++i) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tfinal "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" original = pref.getArguments().get(i);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (original instanceof "); //$NON-NLS-1$ it.append(JvmAnyTypeReference.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = "); //$NON-NLS-1$ it.append(EcoreUtil.class); it.append(".copy(original);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t} else if (original instanceof "); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(") {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tfinal "); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(" wc = EcoreUtil.copy(("); //$NON-NLS-1$ it.append(JvmWildcardTypeReference.class); it.append(") original);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\tfor (final "); //$NON-NLS-1$ it.append(JvmTypeConstraint.class); it.append(" c : wc.getConstraints()) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t\tc.setTypeReference(newTypeRef(context, c.getTypeReference().getIdentifier()));"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = wc;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t} else {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\targs[i] = newTypeRef(context, original.getIdentifier());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfinal "); //$NON-NLS-1$ it.append(TypeReferences.class); it.append(" typeRefs = getTypeReferences();"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn typeRefs.createTypeRef(baseType.getType(), args);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the first parameter is a subtype of the second parameter."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @param context the context."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param subType the subtype to test."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param superType the expected super type."); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the type reference."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isSubTypeOf("); //$NON-NLS-1$ it.append(EObject.class); it.append(" context, "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" subType, "); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" superType) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tif (isTypeReference(superType) && isTypeReference(subType)) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(StandardTypeReferenceOwner.class); it.append(" owner = new "); //$NON-NLS-1$ it.append(StandardTypeReferenceOwner.class); it.append("(services, context);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(LightweightTypeReferenceFactory.class); it.append(" factory = new "); //$NON-NLS-1$ it.append(LightweightTypeReferenceFactory.class); it.append("(owner, false);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(LightweightTypeReference.class); it.append(" reference = factory.toLightweightReference(subType);"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\treturn reference.isSubtypeOf(superType.getType());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn false;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the given object is a valid type reference."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isTypeReference("); //$NON-NLS-1$ it.append(JvmTypeReference.class); it.append(" typeReference) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn (typeReference != null && !typeReference.eIsProxy()"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t&& typeReference.getType() != null && !typeReference.getType().eIsProxy());"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the import's configuration."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the import's configuration."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(IImportsConfiguration.class); it.append(" getImportsConfiguration() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.importsConfiguration;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Compute a unused URI for a synthetic resource."); //$NON-NLS-1$ it.newLine(); it.append("\t * @param resourceSet the resource set in which the resource should be located."); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the uri."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(URI.class); it.append(" computeUnusedUri("); //$NON-NLS-1$ it.append(ResourceSet.class); it.append(" resourceSet) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\tString name = \"__synthetic\";"); //$NON-NLS-1$ it.newLine(); it.append("\t\tfor (int i = 0; i < Integer.MAX_VALUE; ++i) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t"); //$NON-NLS-1$ it.append(URI.class); it.append(" syntheticUri = "); //$NON-NLS-1$ it.append(URI.class); it.append(".createURI(name + i + \".\" + getScriptFileExtension());"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\tif (resourceSet.getResource(syntheticUri, false) == null) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t\treturn syntheticUri;"); //$NON-NLS-1$ it.newLine(); it.append("\t\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\t}"); //$NON-NLS-1$ it.newLine(); it.append("\t\tthrow new IllegalStateException();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the resource factory."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the resource factory."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(IResourceFactory.class); it.append(" getResourceFactory() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.resourceFactory;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies if the type could contains functions with a body."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected boolean isActionBodyAllowed("); //$NON-NLS-1$ it.append(getCodeElementExtractor().getLanguageTopElementType()); it.append(" type) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn "); //$NON-NLS-1$ if (getCodeBuilderConfig().getNoActionBodyTypes().isEmpty()) { it.append("true"); //$NON-NLS-1$ // depends on control dependency: [if], data = [none] } else { it.append("!("); //$NON-NLS-1$ // depends on control dependency: [if], data = [none] boolean first = true; for (String noBodyType : getCodeBuilderConfig().getNoActionBodyTypes()) { if (first) { first = false; // depends on control dependency: [if], data = [none] } else { it.newLine(); // depends on control dependency: [if], data = [none] it.append("\t\t\t|| "); //$NON-NLS-1$ // depends on control dependency: [if], data = [none] } it.append("type instanceof "); //$NON-NLS-1$ // depends on control dependency: [for], data = [none] it.append(new TypeReference(getCodeElementExtractor().getLanguageBasePackage() + "." + noBodyType)); //$NON-NLS-1$ // depends on control dependency: [for], data = [noBodyType] } it.append(")"); //$NON-NLS-1$ // depends on control dependency: [if], data = [none] } it.append(";"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Replies the import manager that stores the imported types."); //$NON-NLS-1$ it.newLine(); it.append("\t *"); //$NON-NLS-1$ it.newLine(); it.append("\t * @return the import manager."); //$NON-NLS-1$ it.newLine(); it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tprotected "); //$NON-NLS-1$ it.append(ImportManager.class); it.append(" getImportManager() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.importManager;"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tprotected String getQualifiedName("); //$NON-NLS-1$ it.append(EObject.class); it.append(" object) {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.qualifiedNameProvider.getFullyQualifiedName(object).toString();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t@"); //$NON-NLS-1$ it.append(Pure.class); it.newLine(); it.append("\tpublic abstract "); //$NON-NLS-1$ it.append(Resource.class); it.append(" eResource();"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\tpublic void dispose() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(Resource.class); it.append(" resource = eResource();"); //$NON-NLS-1$ it.newLine(); it.append("\t\t"); //$NON-NLS-1$ it.append(ResourceSet.class); it.append(" resourceSet = resource.getResourceSet();"); //$NON-NLS-1$ it.newLine(); it.append("\t\tresourceSet.getResources().remove(resource);"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(abstractBuilder, content); javaFile.writeTo(getSrcGen()); } }
public class class_name { public final BELScriptParser.define_namespace_return define_namespace() throws RecognitionException { BELScriptParser.define_namespace_return retval = new BELScriptParser.define_namespace_return(); retval.start = input.LT(1); Object root_0 = null; Token string_literal33=null; Token string_literal34=null; Token string_literal35=null; Token OBJECT_IDENT36=null; Token string_literal37=null; Token string_literal38=null; BELScriptParser.quoted_value_return quoted_value39 = null; Object string_literal33_tree=null; Object string_literal34_tree=null; Object string_literal35_tree=null; Object OBJECT_IDENT36_tree=null; Object string_literal37_tree=null; Object string_literal38_tree=null; paraphrases.push("in define namespace."); try { // BELScript.g:98:5: ( ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) OBJECT_IDENT 'AS' 'URL' quoted_value ) // BELScript.g:99:5: ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) OBJECT_IDENT 'AS' 'URL' quoted_value { root_0 = (Object)adaptor.nil(); // BELScript.g:99:5: ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) // BELScript.g:99:6: 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) { string_literal33=(Token)match(input,27,FOLLOW_27_in_define_namespace429); string_literal33_tree = (Object)adaptor.create(string_literal33); adaptor.addChild(root_0, string_literal33_tree); // BELScript.g:99:15: ( ( 'DEFAULT' )? 'NAMESPACE' ) // BELScript.g:99:16: ( 'DEFAULT' )? 'NAMESPACE' { // BELScript.g:99:16: ( 'DEFAULT' )? int alt6=2; int LA6_0 = input.LA(1); if ( (LA6_0==28) ) { alt6=1; } switch (alt6) { case 1 : // BELScript.g:99:17: 'DEFAULT' { string_literal34=(Token)match(input,28,FOLLOW_28_in_define_namespace433); string_literal34_tree = (Object)adaptor.create(string_literal34); adaptor.addChild(root_0, string_literal34_tree); } break; } string_literal35=(Token)match(input,29,FOLLOW_29_in_define_namespace437); string_literal35_tree = (Object)adaptor.create(string_literal35); adaptor.addChild(root_0, string_literal35_tree); } } OBJECT_IDENT36=(Token)match(input,OBJECT_IDENT,FOLLOW_OBJECT_IDENT_in_define_namespace441); OBJECT_IDENT36_tree = (Object)adaptor.create(OBJECT_IDENT36); adaptor.addChild(root_0, OBJECT_IDENT36_tree); string_literal37=(Token)match(input,30,FOLLOW_30_in_define_namespace443); string_literal37_tree = (Object)adaptor.create(string_literal37); adaptor.addChild(root_0, string_literal37_tree); string_literal38=(Token)match(input,31,FOLLOW_31_in_define_namespace445); string_literal38_tree = (Object)adaptor.create(string_literal38); adaptor.addChild(root_0, string_literal38_tree); pushFollow(FOLLOW_quoted_value_in_define_namespace447); quoted_value39=quoted_value(); state._fsp--; adaptor.addChild(root_0, quoted_value39.getTree()); } retval.stop = input.LT(-1); retval.tree = (Object)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); paraphrases.pop(); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { } return retval; } }
public class class_name { public final BELScriptParser.define_namespace_return define_namespace() throws RecognitionException { BELScriptParser.define_namespace_return retval = new BELScriptParser.define_namespace_return(); retval.start = input.LT(1); Object root_0 = null; Token string_literal33=null; Token string_literal34=null; Token string_literal35=null; Token OBJECT_IDENT36=null; Token string_literal37=null; Token string_literal38=null; BELScriptParser.quoted_value_return quoted_value39 = null; Object string_literal33_tree=null; Object string_literal34_tree=null; Object string_literal35_tree=null; Object OBJECT_IDENT36_tree=null; Object string_literal37_tree=null; Object string_literal38_tree=null; paraphrases.push("in define namespace."); try { // BELScript.g:98:5: ( ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) OBJECT_IDENT 'AS' 'URL' quoted_value ) // BELScript.g:99:5: ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) OBJECT_IDENT 'AS' 'URL' quoted_value { root_0 = (Object)adaptor.nil(); // BELScript.g:99:5: ( 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) ) // BELScript.g:99:6: 'DEFINE' ( ( 'DEFAULT' )? 'NAMESPACE' ) { string_literal33=(Token)match(input,27,FOLLOW_27_in_define_namespace429); string_literal33_tree = (Object)adaptor.create(string_literal33); adaptor.addChild(root_0, string_literal33_tree); // BELScript.g:99:15: ( ( 'DEFAULT' )? 'NAMESPACE' ) // BELScript.g:99:16: ( 'DEFAULT' )? 'NAMESPACE' { // BELScript.g:99:16: ( 'DEFAULT' )? int alt6=2; int LA6_0 = input.LA(1); if ( (LA6_0==28) ) { alt6=1; // depends on control dependency: [if], data = [none] } switch (alt6) { case 1 : // BELScript.g:99:17: 'DEFAULT' { string_literal34=(Token)match(input,28,FOLLOW_28_in_define_namespace433); string_literal34_tree = (Object)adaptor.create(string_literal34); adaptor.addChild(root_0, string_literal34_tree); } break; } string_literal35=(Token)match(input,29,FOLLOW_29_in_define_namespace437); string_literal35_tree = (Object)adaptor.create(string_literal35); adaptor.addChild(root_0, string_literal35_tree); } } OBJECT_IDENT36=(Token)match(input,OBJECT_IDENT,FOLLOW_OBJECT_IDENT_in_define_namespace441); OBJECT_IDENT36_tree = (Object)adaptor.create(OBJECT_IDENT36); adaptor.addChild(root_0, OBJECT_IDENT36_tree); string_literal37=(Token)match(input,30,FOLLOW_30_in_define_namespace443); string_literal37_tree = (Object)adaptor.create(string_literal37); adaptor.addChild(root_0, string_literal37_tree); string_literal38=(Token)match(input,31,FOLLOW_31_in_define_namespace445); string_literal38_tree = (Object)adaptor.create(string_literal38); adaptor.addChild(root_0, string_literal38_tree); pushFollow(FOLLOW_quoted_value_in_define_namespace447); quoted_value39=quoted_value(); state._fsp--; adaptor.addChild(root_0, quoted_value39.getTree()); } retval.stop = input.LT(-1); retval.tree = (Object)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); paraphrases.pop(); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { } return retval; } }
public class class_name { @Override public void shuffle(List<INDArray> arrays, Random rnd, List<int[]> dimensions) { // no dimension - no shuffle if (dimensions == null || dimensions.size() == 0) throw new RuntimeException("Dimension can't be null or 0-length"); if (arrays == null || arrays.size() == 0) throw new RuntimeException("No input arrays provided"); if (dimensions.size() > 1 && arrays.size() != dimensions.size()) throw new IllegalStateException("Number of dimensions do not match number of arrays to shuffle"); Nd4j.getExecutioner().push(); // first we build TAD for input array and dimensions AtomicAllocator allocator = AtomicAllocator.getInstance(); CudaContext context = null; for (int x = 0; x < arrays.size(); x++) { context = allocator.getFlowController().prepareAction(arrays.get(x)); } val zero = arrays.get(0); int tadLength = 1; if (zero.rank() > 1) for (int i = 0; i < dimensions.get(0).length; i++) { tadLength *= zero.shape()[dimensions.get(0)[i]]; } val numTads = zero.length() / tadLength; val map = ArrayUtil.buildInterleavedVector(rnd, (int) numTads); val shuffle = new CudaIntDataBuffer(map); val shuffleMap = allocator.getPointer(shuffle, context); val extras = new PointerPointer(null, // not used context.getOldStream(), allocator.getDeviceIdPointer()); long[] hPointers = new long[arrays.size()]; long[] xPointers = new long[arrays.size()]; long[] xShapes = new long[arrays.size()]; long[] tadShapes = new long[arrays.size()]; long[] tadOffsets = new long[arrays.size()]; for (int i = 0; i < arrays.size(); i++) { val array = arrays.get(i); val x = AtomicAllocator.getInstance().getPointer(array, context); val xShapeInfo = AtomicAllocator.getInstance().getPointer(array.shapeInfoDataBuffer(), context); val tadManager = Nd4j.getExecutioner().getTADManager(); int[] dimension = dimensions.size() > 1 ? dimensions.get(i) : dimensions.get(0); val tadBuffers = tadManager.getTADOnlyShapeInfo(array, dimension); // log.info("Original shape: {}; dimension: {}; TAD shape: {}", array.shapeInfoDataBuffer().asInt(), dimension, tadBuffers.getFirst().asInt()); val tadShapeInfo = AtomicAllocator.getInstance().getPointer(tadBuffers.getFirst(), context); val offsets = tadBuffers.getSecond(); if (zero.rank() != 1 && offsets.length() != numTads) throw new ND4JIllegalStateException("Can't symmetrically shuffle arrays with non-equal number of TADs"); val tadOffset = AtomicAllocator.getInstance().getPointer(offsets, context); hPointers[i] = AtomicAllocator.getInstance().getHostPointer(array.shapeInfoDataBuffer()).address(); xPointers[i] = x.address(); xShapes[i] = xShapeInfo.address(); tadShapes[i] = tadShapeInfo.address(); tadOffsets[i] = tadOffset.address(); } val hostPointers = new LongPointer(hPointers); val hosthost = new PointerPointerWrapper(hostPointers); val tempX = new CudaDoubleDataBuffer(arrays.size()); val tempShapes = new CudaDoubleDataBuffer(arrays.size()); val tempTAD = new CudaDoubleDataBuffer(arrays.size()); val tempOffsets = new CudaDoubleDataBuffer(arrays.size()); AtomicAllocator.getInstance().memcpyBlocking(tempX, new LongPointer(xPointers), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempShapes, new LongPointer(xShapes), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempTAD, new LongPointer(tadShapes), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempOffsets, new LongPointer(tadOffsets), xPointers.length * 8, 0); nativeOps.shuffle(extras, null, hosthost, new PointerPointer(allocator.getPointer(tempX, context)), new PointerPointer(allocator.getPointer(tempShapes, context)), null, null, new PointerPointer(allocator.getPointer(tempX, context)), new PointerPointer(allocator.getPointer(tempShapes, context)), arrays.size(), (IntPointer) shuffleMap, new PointerPointer(allocator.getPointer(tempTAD, context)), new PointerPointer(allocator.getPointer(tempOffsets, context))); for (int f = 0; f < arrays.size(); f++) { allocator.getFlowController().registerAction(context, arrays.get(f)); } // just to keep reference shuffle.address(); hostPointers.address(); tempX.dataType(); tempShapes.dataType(); tempOffsets.dataType(); tempTAD.dataType(); } }
public class class_name { @Override public void shuffle(List<INDArray> arrays, Random rnd, List<int[]> dimensions) { // no dimension - no shuffle if (dimensions == null || dimensions.size() == 0) throw new RuntimeException("Dimension can't be null or 0-length"); if (arrays == null || arrays.size() == 0) throw new RuntimeException("No input arrays provided"); if (dimensions.size() > 1 && arrays.size() != dimensions.size()) throw new IllegalStateException("Number of dimensions do not match number of arrays to shuffle"); Nd4j.getExecutioner().push(); // first we build TAD for input array and dimensions AtomicAllocator allocator = AtomicAllocator.getInstance(); CudaContext context = null; for (int x = 0; x < arrays.size(); x++) { context = allocator.getFlowController().prepareAction(arrays.get(x)); // depends on control dependency: [for], data = [x] } val zero = arrays.get(0); int tadLength = 1; if (zero.rank() > 1) for (int i = 0; i < dimensions.get(0).length; i++) { tadLength *= zero.shape()[dimensions.get(0)[i]]; // depends on control dependency: [for], data = [i] } val numTads = zero.length() / tadLength; val map = ArrayUtil.buildInterleavedVector(rnd, (int) numTads); val shuffle = new CudaIntDataBuffer(map); val shuffleMap = allocator.getPointer(shuffle, context); val extras = new PointerPointer(null, // not used context.getOldStream(), allocator.getDeviceIdPointer()); long[] hPointers = new long[arrays.size()]; long[] xPointers = new long[arrays.size()]; long[] xShapes = new long[arrays.size()]; long[] tadShapes = new long[arrays.size()]; long[] tadOffsets = new long[arrays.size()]; for (int i = 0; i < arrays.size(); i++) { val array = arrays.get(i); val x = AtomicAllocator.getInstance().getPointer(array, context); val xShapeInfo = AtomicAllocator.getInstance().getPointer(array.shapeInfoDataBuffer(), context); val tadManager = Nd4j.getExecutioner().getTADManager(); int[] dimension = dimensions.size() > 1 ? dimensions.get(i) : dimensions.get(0); val tadBuffers = tadManager.getTADOnlyShapeInfo(array, dimension); // log.info("Original shape: {}; dimension: {}; TAD shape: {}", array.shapeInfoDataBuffer().asInt(), dimension, tadBuffers.getFirst().asInt()); val tadShapeInfo = AtomicAllocator.getInstance().getPointer(tadBuffers.getFirst(), context); val offsets = tadBuffers.getSecond(); if (zero.rank() != 1 && offsets.length() != numTads) throw new ND4JIllegalStateException("Can't symmetrically shuffle arrays with non-equal number of TADs"); val tadOffset = AtomicAllocator.getInstance().getPointer(offsets, context); hPointers[i] = AtomicAllocator.getInstance().getHostPointer(array.shapeInfoDataBuffer()).address(); // depends on control dependency: [for], data = [i] xPointers[i] = x.address(); // depends on control dependency: [for], data = [i] xShapes[i] = xShapeInfo.address(); // depends on control dependency: [for], data = [i] tadShapes[i] = tadShapeInfo.address(); // depends on control dependency: [for], data = [i] tadOffsets[i] = tadOffset.address(); // depends on control dependency: [for], data = [i] } val hostPointers = new LongPointer(hPointers); val hosthost = new PointerPointerWrapper(hostPointers); val tempX = new CudaDoubleDataBuffer(arrays.size()); val tempShapes = new CudaDoubleDataBuffer(arrays.size()); val tempTAD = new CudaDoubleDataBuffer(arrays.size()); val tempOffsets = new CudaDoubleDataBuffer(arrays.size()); AtomicAllocator.getInstance().memcpyBlocking(tempX, new LongPointer(xPointers), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempShapes, new LongPointer(xShapes), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempTAD, new LongPointer(tadShapes), xPointers.length * 8, 0); AtomicAllocator.getInstance().memcpyBlocking(tempOffsets, new LongPointer(tadOffsets), xPointers.length * 8, 0); nativeOps.shuffle(extras, null, hosthost, new PointerPointer(allocator.getPointer(tempX, context)), new PointerPointer(allocator.getPointer(tempShapes, context)), null, null, new PointerPointer(allocator.getPointer(tempX, context)), new PointerPointer(allocator.getPointer(tempShapes, context)), arrays.size(), (IntPointer) shuffleMap, new PointerPointer(allocator.getPointer(tempTAD, context)), new PointerPointer(allocator.getPointer(tempOffsets, context))); for (int f = 0; f < arrays.size(); f++) { allocator.getFlowController().registerAction(context, arrays.get(f)); // depends on control dependency: [for], data = [f] } // just to keep reference shuffle.address(); hostPointers.address(); tempX.dataType(); tempShapes.dataType(); tempOffsets.dataType(); tempTAD.dataType(); } }
public class class_name { private void buildImplementedMethodList(boolean sort) { List<Type> intfacs = Util.getAllInterfaces(classdoc, configuration, sort); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext(); ) { Type interfaceType = iter.next(); MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); if (!overridingMethodFound(found)) { methlist.add(found); interfaces.put(found, interfaceType); } } } } }
public class class_name { private void buildImplementedMethodList(boolean sort) { List<Type> intfacs = Util.getAllInterfaces(classdoc, configuration, sort); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext(); ) { Type interfaceType = iter.next(); MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); // depends on control dependency: [if], data = [(found] if (!overridingMethodFound(found)) { methlist.add(found); // depends on control dependency: [if], data = [none] interfaces.put(found, interfaceType); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { private static Long getContentSize(final Node ds) { try { long size = 0L; if (ds.hasNode(JCR_CONTENT)) { final Node contentNode = ds.getNode(JCR_CONTENT); if (contentNode.hasProperty(JCR_DATA)) { size = ds.getNode(JCR_CONTENT).getProperty(JCR_DATA) .getBinary().getSize(); } } return size; } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } } }
public class class_name { private static Long getContentSize(final Node ds) { try { long size = 0L; if (ds.hasNode(JCR_CONTENT)) { final Node contentNode = ds.getNode(JCR_CONTENT); if (contentNode.hasProperty(JCR_DATA)) { size = ds.getNode(JCR_CONTENT).getProperty(JCR_DATA) .getBinary().getSize(); // depends on control dependency: [if], data = [none] } } return size; // depends on control dependency: [try], data = [none] } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) { final Map<String, String> environment = generateEnvVarsFromContext(dataContext); if (null != environment) { for (final Map.Entry<String, String> entry : environment.entrySet()) { final String key = entry.getKey(); if (null != key && null != entry.getValue()) { final Environment.Variable env = new Environment.Variable(); env.setKey(key); env.setValue(entry.getValue()); sshexecTask.addEnv(env); } } } } }
public class class_name { public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) { final Map<String, String> environment = generateEnvVarsFromContext(dataContext); if (null != environment) { for (final Map.Entry<String, String> entry : environment.entrySet()) { final String key = entry.getKey(); if (null != key && null != entry.getValue()) { final Environment.Variable env = new Environment.Variable(); env.setKey(key); // depends on control dependency: [if], data = [none] env.setValue(entry.getValue()); // depends on control dependency: [if], data = [none] sshexecTask.addEnv(env); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public int dot(int[] other) { int dot = 0; for (int c = 0; c < used && indices[c] < other.length; c++) { if (indices[c] > Integer.MAX_VALUE) { break; } dot += values[c] * other[SafeCast.safeLongToInt(indices[c])]; } return dot; } }
public class class_name { public int dot(int[] other) { int dot = 0; for (int c = 0; c < used && indices[c] < other.length; c++) { if (indices[c] > Integer.MAX_VALUE) { break; } dot += values[c] * other[SafeCast.safeLongToInt(indices[c])]; // depends on control dependency: [for], data = [c] } return dot; } }
public class class_name { public void send(Object object) { if (object instanceof File) { file((File) object); } else { send(object, getContentType()); } } }
public class class_name { public void send(Object object) { if (object instanceof File) { file((File) object); // depends on control dependency: [if], data = [none] } else { send(object, getContentType()); // depends on control dependency: [if], data = [none] } } }
public class class_name { public void marshall(TagFilter tagFilter, ProtocolMarshaller protocolMarshaller) { if (tagFilter == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tagFilter.getTag(), TAG_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(TagFilter tagFilter, ProtocolMarshaller protocolMarshaller) { if (tagFilter == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tagFilter.getTag(), TAG_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 { private long findMaxLen(long pLength) { if (hasLength && left < pLength) { return Math.max(left, 0); } else { return Math.max(pLength, 0); } } }
public class class_name { private long findMaxLen(long pLength) { if (hasLength && left < pLength) { return Math.max(left, 0); // depends on control dependency: [if], data = [none] } else { return Math.max(pLength, 0); // depends on control dependency: [if], data = [none] } } }
public class class_name { @Api public void setVisible(boolean visible) { if (visible != this.visible) { this.visible = visible; updateShowing(false); handlerManager.fireEvent(new LayerShownEvent(this)); } } }
public class class_name { @Api public void setVisible(boolean visible) { if (visible != this.visible) { this.visible = visible; // depends on control dependency: [if], data = [none] updateShowing(false); // depends on control dependency: [if], data = [none] handlerManager.fireEvent(new LayerShownEvent(this)); // depends on control dependency: [if], data = [none] } } }
public class class_name { protected ArrayList<SIPNode> getReachableSIPNodeInfo(SipLoadBalancer balancer, ArrayList<SIPNode> info) { InetAddress balancerAddr = balancer.getAddress(); if (balancerAddr.isLoopbackAddress()) { return info; } ArrayList<SIPNode> rv = new ArrayList<SIPNode>(); for(SIPNode node: info) { if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace("Checking if " + node + " is reachable"); } try { NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getByName(node.getIp())); // FIXME How can I determine the ttl? boolean b = balancerAddr.isReachable(ni, 5, 900); if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace(node + " is reachable ? " + b); } if(b) { if(balancer.getCustomInfo() != null && !balancer.getCustomInfo().isEmpty()) { for(Entry<Object, Object> entry : balancer.getCustomInfo().entrySet()) { if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) { logger.logDebug("Adding custom info with key " + (String)entry.getKey() + " and value " + (String)entry.getValue()); } node.getProperties().put((String)entry.getKey(), (String)entry.getValue()); } } rv.add(node); } } catch (IOException e) { logger.logError("IOException", e); } } if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace("Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]"); } return rv; } }
public class class_name { protected ArrayList<SIPNode> getReachableSIPNodeInfo(SipLoadBalancer balancer, ArrayList<SIPNode> info) { InetAddress balancerAddr = balancer.getAddress(); if (balancerAddr.isLoopbackAddress()) { return info; // depends on control dependency: [if], data = [none] } ArrayList<SIPNode> rv = new ArrayList<SIPNode>(); for(SIPNode node: info) { if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace("Checking if " + node + " is reachable"); // depends on control dependency: [if], data = [none] } try { NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getByName(node.getIp())); // FIXME How can I determine the ttl? boolean b = balancerAddr.isReachable(ni, 5, 900); if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace(node + " is reachable ? " + b); // depends on control dependency: [if], data = [none] } if(b) { if(balancer.getCustomInfo() != null && !balancer.getCustomInfo().isEmpty()) { for(Entry<Object, Object> entry : balancer.getCustomInfo().entrySet()) { if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) { logger.logDebug("Adding custom info with key " + (String)entry.getKey() + " and value " + (String)entry.getValue()); // depends on control dependency: [if], data = [none] } node.getProperties().put((String)entry.getKey(), (String)entry.getValue()); // depends on control dependency: [for], data = [entry] } } rv.add(node); // depends on control dependency: [if], data = [none] } } catch (IOException e) { logger.logError("IOException", e); } // depends on control dependency: [catch], data = [none] } if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) { logger.logTrace("Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]"); // depends on control dependency: [if], data = [none] } return rv; } }
public class class_name { private void updatePoint() { clearImagePoint(); CmsPoint nativePoint; if (m_focalPoint == null) { CmsPoint cropCenter = getCropCenter(); nativePoint = cropCenter; } else if (!getNativeCropRegion().contains(m_focalPoint)) { return; } else { nativePoint = m_focalPoint; } m_pointWidget = new CmsFocalPoint(CmsFocalPointController.this); boolean isDefault = m_savedFocalPoint == null; m_pointWidget.setIsDefault(isDefault); m_container.add(m_pointWidget); CmsPoint screenPoint = m_coordinateTransform.transformBack(nativePoint); m_pointWidget.setCenterCoordsRelativeToParent((int)screenPoint.getX(), (int)screenPoint.getY()); } }
public class class_name { private void updatePoint() { clearImagePoint(); CmsPoint nativePoint; if (m_focalPoint == null) { CmsPoint cropCenter = getCropCenter(); nativePoint = cropCenter; // depends on control dependency: [if], data = [none] } else if (!getNativeCropRegion().contains(m_focalPoint)) { return; // depends on control dependency: [if], data = [none] } else { nativePoint = m_focalPoint; // depends on control dependency: [if], data = [none] } m_pointWidget = new CmsFocalPoint(CmsFocalPointController.this); boolean isDefault = m_savedFocalPoint == null; m_pointWidget.setIsDefault(isDefault); m_container.add(m_pointWidget); CmsPoint screenPoint = m_coordinateTransform.transformBack(nativePoint); m_pointWidget.setCenterCoordsRelativeToParent((int)screenPoint.getX(), (int)screenPoint.getY()); } }
public class class_name { public void setEveryWorkingDay(final boolean isEveryWorkingDay) { if (m_model.isEveryWorkingDay() != isEveryWorkingDay) { removeExceptionsOnChange(new Command() { public void execute() { m_model.setEveryWorkingDay(Boolean.valueOf(isEveryWorkingDay)); m_model.setInterval(getPatternDefaultValues().getInterval()); onValueChange(); } }); } } }
public class class_name { public void setEveryWorkingDay(final boolean isEveryWorkingDay) { if (m_model.isEveryWorkingDay() != isEveryWorkingDay) { removeExceptionsOnChange(new Command() { public void execute() { m_model.setEveryWorkingDay(Boolean.valueOf(isEveryWorkingDay)); m_model.setInterval(getPatternDefaultValues().getInterval()); onValueChange(); } }); // depends on control dependency: [if], data = [none] } } }
public class class_name { private RRFedNonFedBudgetDocument getRRFedNonFedBudget() { RRFedNonFedBudgetDocument rrFedNonFedBudgetDocument = RRFedNonFedBudgetDocument.Factory.newInstance(); RRFedNonFedBudgetDocument.RRFedNonFedBudget fedNonFedBudget = RRFedNonFedBudgetDocument.RRFedNonFedBudget.Factory .newInstance(); fedNonFedBudget.setFormVersion(FormVersion.v1_0.getVersion()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { fedNonFedBudget.setDUNSID(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getDunsNumber()); } if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { fedNonFedBudget.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getOrganizationName()); } fedNonFedBudget.setBudgetType(BudgetTypeDataType.PROJECT); // Set default values for mandatory fields List<BudgetPeriodDto> budgetPeriodList; BudgetSummaryDto budgetSummary = null; try { budgetPeriodList = s2sBudgetCalculatorService.getBudgetPeriods(pdDoc); budgetSummary = s2sBudgetCalculatorService.getBudgetInfo(pdDoc,budgetPeriodList); } catch (S2SException e) { LOG.error(e.getMessage(), e); return rrFedNonFedBudgetDocument; } for (BudgetPeriodDto budgetPeriodData : budgetPeriodList) { if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P1.getNum()) { fedNonFedBudget.setBudgetYear1(getBudgetYear1DataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P2.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear2(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P3.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear3(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P4.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear4(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P5.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear5(getBudgetYearDataType(budgetPeriodData)); } } fedNonFedBudget.setBudgetSummary(getBudgetSummary(budgetSummary)); rrFedNonFedBudgetDocument.setRRFedNonFedBudget(fedNonFedBudget); return rrFedNonFedBudgetDocument; } }
public class class_name { private RRFedNonFedBudgetDocument getRRFedNonFedBudget() { RRFedNonFedBudgetDocument rrFedNonFedBudgetDocument = RRFedNonFedBudgetDocument.Factory.newInstance(); RRFedNonFedBudgetDocument.RRFedNonFedBudget fedNonFedBudget = RRFedNonFedBudgetDocument.RRFedNonFedBudget.Factory .newInstance(); fedNonFedBudget.setFormVersion(FormVersion.v1_0.getVersion()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { fedNonFedBudget.setDUNSID(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getDunsNumber()); // depends on control dependency: [if], data = [(pdDoc.getDevelopmentProposal().getApplicantOrganization()] } if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { fedNonFedBudget.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getOrganizationName()); // depends on control dependency: [if], data = [(pdDoc.getDevelopmentProposal().getApplicantOrganization()] } fedNonFedBudget.setBudgetType(BudgetTypeDataType.PROJECT); // Set default values for mandatory fields List<BudgetPeriodDto> budgetPeriodList; BudgetSummaryDto budgetSummary = null; try { budgetPeriodList = s2sBudgetCalculatorService.getBudgetPeriods(pdDoc); // depends on control dependency: [try], data = [none] budgetSummary = s2sBudgetCalculatorService.getBudgetInfo(pdDoc,budgetPeriodList); // depends on control dependency: [try], data = [none] } catch (S2SException e) { LOG.error(e.getMessage(), e); return rrFedNonFedBudgetDocument; } // depends on control dependency: [catch], data = [none] for (BudgetPeriodDto budgetPeriodData : budgetPeriodList) { if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P1.getNum()) { fedNonFedBudget.setBudgetYear1(getBudgetYear1DataType(budgetPeriodData)); // depends on control dependency: [if], data = [none] } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P2.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear2(getBudgetYearDataType(budgetPeriodData)); // depends on control dependency: [if], data = [Budg] } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P3.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear3(getBudgetYearDataType(budgetPeriodData)); // depends on control dependency: [if], data = [Budg] } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P4.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear4(getBudgetYearDataType(budgetPeriodData)); // depends on control dependency: [if], data = [Budg] } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P5.getNum() && budgetPeriodData.getLineItemCount() > 0) { fedNonFedBudget.setBudgetYear5(getBudgetYearDataType(budgetPeriodData)); // depends on control dependency: [if], data = [Budg] } } fedNonFedBudget.setBudgetSummary(getBudgetSummary(budgetSummary)); rrFedNonFedBudgetDocument.setRRFedNonFedBudget(fedNonFedBudget); return rrFedNonFedBudgetDocument; } }
public class class_name { private static String[] getAttributeValues(final RDNSequence rdnSequence, final AttributeType attribute) { val values = new ArrayList<String>(); for (val rdn : rdnSequence.backward()) { for (val attr : rdn.getAttributes()) { if (attr.getType().equals(attribute)) { values.add(attr.getValue()); } } } return values.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } }
public class class_name { private static String[] getAttributeValues(final RDNSequence rdnSequence, final AttributeType attribute) { val values = new ArrayList<String>(); for (val rdn : rdnSequence.backward()) { for (val attr : rdn.getAttributes()) { if (attr.getType().equals(attribute)) { values.add(attr.getValue()); // depends on control dependency: [if], data = [none] } } } return values.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } }
public class class_name { protected void entryRemoved (V entry) { if (entry != null) { _size -= _sizer.computeSize(entry); if (_remobs != null) { _remobs.removedFromMap(this, entry); } } } }
public class class_name { protected void entryRemoved (V entry) { if (entry != null) { _size -= _sizer.computeSize(entry); // depends on control dependency: [if], data = [(entry] if (_remobs != null) { _remobs.removedFromMap(this, entry); // depends on control dependency: [if], data = [none] } } } }
public class class_name { private void handleInitiateResponseMessage(InitiateResponseMessage message) { //For mis-routed transactions, no update for truncation handle or duplicated counter if (message.isMisrouted()){ m_mailbox.send(message.getInitiatorHSId(), message); return; } /** * A shortcut read is a read operation sent to any replica and completed with no * confirmation or communication with other replicas. In a partition scenario, it's * possible to read an unconfirmed transaction's writes that will be lost. */ final long spHandle = message.getSpHandle(); final DuplicateCounterKey dcKey = new DuplicateCounterKey(message.getTxnId(), spHandle); DuplicateCounter counter = m_duplicateCounters.get(dcKey); final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPI); // All reads will have no duplicate counter. // Avoid all the lookup below. // Also, don't update the truncation handle, since it won't have meaning for anyone. if (message.isReadOnly()) { if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync("initsp", MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()))); } // InvocationDispatcher routes SAFE reads to SPI only assert(m_bufferedReadLog != null); m_bufferedReadLog.offer(m_mailbox, message, m_repairLogTruncationHandle); return; } if (counter != null) { String traceName = "initsp"; if (message.m_sourceHSId != m_mailbox.getHSId()) { traceName = "replicatesp"; } String finalTraceName = traceName; if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync(finalTraceName, MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()), "hash", message.getClientResponseData().getHashes()[0])); } int result = counter.offer(message); if (result == DuplicateCounter.DONE) { m_duplicateCounters.remove(dcKey); final TransactionState txn = m_outstandingTxns.get(message.getTxnId()); setRepairLogTruncationHandle(spHandle, (txn != null && txn.isLeaderMigrationInvolved())); m_mailbox.send(counter.m_destinationId, counter.m_lastResponse); } else if (result == DuplicateCounter.MISMATCH) { if (m_isLeader && m_sendToHSIds.length > 0) { StringBuilder sb = new StringBuilder(); for (long hsId : m_sendToHSIds) { sb.append(CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId)).append(" "); } hostLog.info("Send dump plan message to other replicas: " + sb.toString()); m_mailbox.send(m_sendToHSIds, new DumpPlanThenExitMessage(counter.getStoredProcedureName())); } RealVoltDB.printDiagnosticInformation(VoltDB.instance().getCatalogContext(), counter.getStoredProcedureName(), m_procSet); VoltDB.crashLocalVoltDB("HASH MISMATCH: replicas produced different results.", true, null); } else if (result == DuplicateCounter.ABORT) { if (m_isLeader && m_sendToHSIds.length > 0) { StringBuilder sb = new StringBuilder(); for (long hsId : m_sendToHSIds) { sb.append(CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId)).append(" "); } hostLog.info("Send dump plan message to other replicas: " + sb.toString()); m_mailbox.send(m_sendToHSIds, new DumpPlanThenExitMessage(counter.getStoredProcedureName())); } RealVoltDB.printDiagnosticInformation(VoltDB.instance().getCatalogContext(), counter.getStoredProcedureName(), m_procSet); VoltDB.crashLocalVoltDB("HASH MISMATCH: transaction succeeded on one replica but failed on another replica.", true, null); } } else { if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync("initsp", MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()))); } // the initiatorHSId is the ClientInterface mailbox. // this will be on SPI without k-safety or replica only with k-safety assert(!message.isReadOnly()); setRepairLogTruncationHandle(spHandle, false); //BabySitter's thread (updateReplicas) could clean up a duplicate counter and send a transaction response to ClientInterface //if the duplicate counter contains only the replica's HSIDs from failed hosts. That is, a response from a replica could get here //AFTER the transaction is completed. Such a response message should not be further propagated. if (m_mailbox.getHSId() != message.getInitiatorHSId()) { m_mailbox.send(message.getInitiatorHSId(), message); } } //notify the new partition leader that the old leader has completed the Txns if needed. //m_mailbox can be MockMailBox for unit test. if (!m_isLeader && m_mailbox instanceof InitiatorMailbox) { ((InitiatorMailbox)m_mailbox).notifyNewLeaderOfTxnDoneIfNeeded(); } } }
public class class_name { private void handleInitiateResponseMessage(InitiateResponseMessage message) { //For mis-routed transactions, no update for truncation handle or duplicated counter if (message.isMisrouted()){ m_mailbox.send(message.getInitiatorHSId(), message); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } /** * A shortcut read is a read operation sent to any replica and completed with no * confirmation or communication with other replicas. In a partition scenario, it's * possible to read an unconfirmed transaction's writes that will be lost. */ final long spHandle = message.getSpHandle(); final DuplicateCounterKey dcKey = new DuplicateCounterKey(message.getTxnId(), spHandle); DuplicateCounter counter = m_duplicateCounters.get(dcKey); final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPI); // All reads will have no duplicate counter. // Avoid all the lookup below. // Also, don't update the truncation handle, since it won't have meaning for anyone. if (message.isReadOnly()) { if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync("initsp", MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()))); // depends on control dependency: [if], data = [none] } // InvocationDispatcher routes SAFE reads to SPI only assert(m_bufferedReadLog != null); // depends on control dependency: [if], data = [none] m_bufferedReadLog.offer(m_mailbox, message, m_repairLogTruncationHandle); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } if (counter != null) { String traceName = "initsp"; if (message.m_sourceHSId != m_mailbox.getHSId()) { traceName = "replicatesp"; // depends on control dependency: [if], data = [none] } String finalTraceName = traceName; if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync(finalTraceName, MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()), "hash", message.getClientResponseData().getHashes()[0])); // depends on control dependency: [if], data = [none] } int result = counter.offer(message); if (result == DuplicateCounter.DONE) { m_duplicateCounters.remove(dcKey); // depends on control dependency: [if], data = [none] final TransactionState txn = m_outstandingTxns.get(message.getTxnId()); setRepairLogTruncationHandle(spHandle, (txn != null && txn.isLeaderMigrationInvolved())); // depends on control dependency: [if], data = [none] m_mailbox.send(counter.m_destinationId, counter.m_lastResponse); // depends on control dependency: [if], data = [none] } else if (result == DuplicateCounter.MISMATCH) { if (m_isLeader && m_sendToHSIds.length > 0) { StringBuilder sb = new StringBuilder(); for (long hsId : m_sendToHSIds) { sb.append(CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId)).append(" "); // depends on control dependency: [for], data = [hsId] } hostLog.info("Send dump plan message to other replicas: " + sb.toString()); // depends on control dependency: [if], data = [none] m_mailbox.send(m_sendToHSIds, new DumpPlanThenExitMessage(counter.getStoredProcedureName())); // depends on control dependency: [if], data = [none] } RealVoltDB.printDiagnosticInformation(VoltDB.instance().getCatalogContext(), counter.getStoredProcedureName(), m_procSet); // depends on control dependency: [if], data = [none] VoltDB.crashLocalVoltDB("HASH MISMATCH: replicas produced different results.", true, null); // depends on control dependency: [if], data = [none] } else if (result == DuplicateCounter.ABORT) { if (m_isLeader && m_sendToHSIds.length > 0) { StringBuilder sb = new StringBuilder(); for (long hsId : m_sendToHSIds) { sb.append(CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId)).append(" "); // depends on control dependency: [for], data = [hsId] } hostLog.info("Send dump plan message to other replicas: " + sb.toString()); // depends on control dependency: [if], data = [none] m_mailbox.send(m_sendToHSIds, new DumpPlanThenExitMessage(counter.getStoredProcedureName())); // depends on control dependency: [if], data = [none] } RealVoltDB.printDiagnosticInformation(VoltDB.instance().getCatalogContext(), counter.getStoredProcedureName(), m_procSet); // depends on control dependency: [if], data = [none] VoltDB.crashLocalVoltDB("HASH MISMATCH: transaction succeeded on one replica but failed on another replica.", true, null); // depends on control dependency: [if], data = [none] } } else { if (traceLog != null) { traceLog.add(() -> VoltTrace.endAsync("initsp", MiscUtils.hsIdPairTxnIdToString(m_mailbox.getHSId(), message.m_sourceHSId, message.getSpHandle(), message.getClientInterfaceHandle()))); // depends on control dependency: [if], data = [none] } // the initiatorHSId is the ClientInterface mailbox. // this will be on SPI without k-safety or replica only with k-safety assert(!message.isReadOnly()); // depends on control dependency: [if], data = [none] setRepairLogTruncationHandle(spHandle, false); // depends on control dependency: [if], data = [none] //BabySitter's thread (updateReplicas) could clean up a duplicate counter and send a transaction response to ClientInterface //if the duplicate counter contains only the replica's HSIDs from failed hosts. That is, a response from a replica could get here //AFTER the transaction is completed. Such a response message should not be further propagated. if (m_mailbox.getHSId() != message.getInitiatorHSId()) { m_mailbox.send(message.getInitiatorHSId(), message); // depends on control dependency: [if], data = [none] } } //notify the new partition leader that the old leader has completed the Txns if needed. //m_mailbox can be MockMailBox for unit test. if (!m_isLeader && m_mailbox instanceof InitiatorMailbox) { ((InitiatorMailbox)m_mailbox).notifyNewLeaderOfTxnDoneIfNeeded(); // depends on control dependency: [if], data = [none] } } }
public class class_name { private void bindArray(final TransformContext transformContext, final Object values) { int length = Array.getLength(values); if (length == 0) { throw new ParameterNotFoundRuntimeException("Parameter is not set. [" + expression + "]"); } transformContext.addSqlPart("(?"); transformContext.addBindVariable(Array.get(values, 0)); for (int i = 1; i < length; i++) { transformContext.addSqlPart(", ?"); transformContext.addBindVariable(Array.get(values, i)); } transformContext.addSqlPart(")"); if (outputBindComment) { transformContext.addSqlPart("/*").addSqlPart(expression).addSqlPart("*/"); } transformContext.addBindName(expression); } }
public class class_name { private void bindArray(final TransformContext transformContext, final Object values) { int length = Array.getLength(values); if (length == 0) { throw new ParameterNotFoundRuntimeException("Parameter is not set. [" + expression + "]"); } transformContext.addSqlPart("(?"); transformContext.addBindVariable(Array.get(values, 0)); for (int i = 1; i < length; i++) { transformContext.addSqlPart(", ?"); // depends on control dependency: [for], data = [none] transformContext.addBindVariable(Array.get(values, i)); // depends on control dependency: [for], data = [i] } transformContext.addSqlPart(")"); if (outputBindComment) { transformContext.addSqlPart("/*").addSqlPart(expression).addSqlPart("*/"); // depends on control dependency: [if], data = [none] } transformContext.addBindName(expression); } }
public class class_name { private static void replaceWords(StringBuilder input, String[] words, String[] replaces, boolean ignoreCase) { if (input == null || input.length()==0 || words == null || words.length == 0 || replaces == null || replaces.length == 0) { return; } // the same number of word to replace and replaces to use if (words.length != replaces.length) { throw new IllegalArgumentException(String.format("Words (%d) and replaces (%d) lengths should be equals", words.length, replaces.length)); } for(int i = 0; i < words.length; i++) { replaceWord(input, words[i], replaces[i], ignoreCase); } } }
public class class_name { private static void replaceWords(StringBuilder input, String[] words, String[] replaces, boolean ignoreCase) { if (input == null || input.length()==0 || words == null || words.length == 0 || replaces == null || replaces.length == 0) { return; // depends on control dependency: [if], data = [none] } // the same number of word to replace and replaces to use if (words.length != replaces.length) { throw new IllegalArgumentException(String.format("Words (%d) and replaces (%d) lengths should be equals", words.length, replaces.length)); } for(int i = 0; i < words.length; i++) { replaceWord(input, words[i], replaces[i], ignoreCase); // depends on control dependency: [for], data = [i] } } }
public class class_name { public static <T> T unmarshal(final JAXBContext ctx, final String xmlData, final XmlAdapter<?, ?>[] adapters) { if (xmlData == null) { return null; } return unmarshal(ctx, new StringReader(xmlData), adapters); } }
public class class_name { public static <T> T unmarshal(final JAXBContext ctx, final String xmlData, final XmlAdapter<?, ?>[] adapters) { if (xmlData == null) { return null; // depends on control dependency: [if], data = [none] } return unmarshal(ctx, new StringReader(xmlData), adapters); } }
public class class_name { public void invert() { final boolean isEventFirable = isEventFirable(); setEventFirable(false); try { final int count = this.roadSegments.getRoadSegmentCount(); // Invert the segments this.roadSegments.invert(); // Invert the bus halts and their indexes. final int middle = this.validHalts.size() / 2; for (int i = 0, j = this.validHalts.size() - 1; i < middle; ++i, --j) { final BusItineraryHalt h1 = this.validHalts.get(i); final BusItineraryHalt h2 = this.validHalts.get(j); this.validHalts.set(i, h2); this.validHalts.set(j, h1); int idx = h1.getRoadSegmentIndex(); idx = count - idx - 1; h1.setRoadSegmentIndex(idx); idx = h2.getRoadSegmentIndex(); idx = count - idx - 1; h2.setRoadSegmentIndex(idx); } if (middle * 2 != this.validHalts.size()) { final BusItineraryHalt h1 = this.validHalts.get(middle); int idx = h1.getRoadSegmentIndex(); idx = count - idx - 1; h1.setRoadSegmentIndex(idx); } } finally { setEventFirable(isEventFirable); } fireShapeChanged(new BusChangeEvent(this, BusChangeEventType.ITINERARY_INVERTED, this, indexInParent(), "busHalts", //$NON-NLS-1$ null, null)); } }
public class class_name { public void invert() { final boolean isEventFirable = isEventFirable(); setEventFirable(false); try { final int count = this.roadSegments.getRoadSegmentCount(); // Invert the segments this.roadSegments.invert(); // depends on control dependency: [try], data = [none] // Invert the bus halts and their indexes. final int middle = this.validHalts.size() / 2; for (int i = 0, j = this.validHalts.size() - 1; i < middle; ++i, --j) { final BusItineraryHalt h1 = this.validHalts.get(i); final BusItineraryHalt h2 = this.validHalts.get(j); this.validHalts.set(i, h2); // depends on control dependency: [for], data = [i] this.validHalts.set(j, h1); // depends on control dependency: [for], data = [none] int idx = h1.getRoadSegmentIndex(); idx = count - idx - 1; // depends on control dependency: [for], data = [none] h1.setRoadSegmentIndex(idx); // depends on control dependency: [for], data = [none] idx = h2.getRoadSegmentIndex(); // depends on control dependency: [for], data = [none] idx = count - idx - 1; // depends on control dependency: [for], data = [none] h2.setRoadSegmentIndex(idx); // depends on control dependency: [for], data = [none] } if (middle * 2 != this.validHalts.size()) { final BusItineraryHalt h1 = this.validHalts.get(middle); int idx = h1.getRoadSegmentIndex(); idx = count - idx - 1; // depends on control dependency: [if], data = [none] h1.setRoadSegmentIndex(idx); // depends on control dependency: [if], data = [none] } } finally { setEventFirable(isEventFirable); } fireShapeChanged(new BusChangeEvent(this, BusChangeEventType.ITINERARY_INVERTED, this, indexInParent(), "busHalts", //$NON-NLS-1$ null, null)); } }
public class class_name { private void locateNode(final String address, final Iterator<String> nodes, final Handler<AsyncResult<String>> doneHandler) { if (nodes.hasNext()) { final String node = nodes.next(); vertx.eventBus().sendWithTimeout(node, new JsonObject().putString("action", "ping"), 1000, new Handler<AsyncResult<Message<JsonObject>>>() { @Override public void handle(AsyncResult<Message<JsonObject>> result) { if (result.failed() || result.result().body().getString("status", "ok").equals("error")) { removeNode(address, node); locateNode(address, nodes, doneHandler); } else { new DefaultFutureResult<String>(node).setHandler(doneHandler); } } }); } else { new DefaultFutureResult<String>(new IllegalStateException("No local nodes found")).setHandler(doneHandler); } } }
public class class_name { private void locateNode(final String address, final Iterator<String> nodes, final Handler<AsyncResult<String>> doneHandler) { if (nodes.hasNext()) { final String node = nodes.next(); vertx.eventBus().sendWithTimeout(node, new JsonObject().putString("action", "ping"), 1000, new Handler<AsyncResult<Message<JsonObject>>>() { @Override public void handle(AsyncResult<Message<JsonObject>> result) { if (result.failed() || result.result().body().getString("status", "ok").equals("error")) { removeNode(address, node); // depends on control dependency: [if], data = [none] locateNode(address, nodes, doneHandler); // depends on control dependency: [if], data = [none] } else { new DefaultFutureResult<String>(node).setHandler(doneHandler); // depends on control dependency: [if], data = [none] } } }); // depends on control dependency: [if], data = [none] } else { new DefaultFutureResult<String>(new IllegalStateException("No local nodes found")).setHandler(doneHandler); // depends on control dependency: [if], data = [none] } } }
public class class_name { public boolean present() { boolean isPresent = false; try { element.getWebElement().getText(); isPresent = true; } catch (NoSuchElementException | StaleElementReferenceException e) { log.info(e); } return isPresent; } }
public class class_name { public boolean present() { boolean isPresent = false; try { element.getWebElement().getText(); // depends on control dependency: [try], data = [none] isPresent = true; // depends on control dependency: [try], data = [none] } catch (NoSuchElementException | StaleElementReferenceException e) { log.info(e); } // depends on control dependency: [catch], data = [none] return isPresent; } }
public class class_name { private void onSetComparatorType(CfDef cfDef, Properties cfProperties, StringBuilder builder) { String comparatorType = cfProperties.getProperty(CassandraConstants.COMPARATOR_TYPE); if (comparatorType != null) { if (builder != null) { // TODO:::nothing available. } else { cfDef.setComparator_type(comparatorType); } } } }
public class class_name { private void onSetComparatorType(CfDef cfDef, Properties cfProperties, StringBuilder builder) { String comparatorType = cfProperties.getProperty(CassandraConstants.COMPARATOR_TYPE); if (comparatorType != null) { if (builder != null) { // TODO:::nothing available. } else { cfDef.setComparator_type(comparatorType); // depends on control dependency: [if], data = [none] } } } }
public class class_name { private void appendAffix(StringBuffer buffer, String affixPattern, String expAffix, boolean localized) { if (affixPattern == null) { appendAffix(buffer, expAffix, localized); } else { int i; for (int pos=0; pos<affixPattern.length(); pos=i) { i = affixPattern.indexOf(QUOTE, pos); if (i < 0) { appendAffix(buffer, affixPattern.substring(pos), localized); break; } if (i > pos) { appendAffix(buffer, affixPattern.substring(pos, i), localized); } char c = affixPattern.charAt(++i); ++i; if (c == QUOTE) { buffer.append(c); // Fall through and append another QUOTE below } else if (c == CURRENCY_SIGN && i<affixPattern.length() && affixPattern.charAt(i) == CURRENCY_SIGN) { ++i; buffer.append(c); // Fall through and append another CURRENCY_SIGN below } else if (localized) { switch (c) { case PATTERN_PERCENT: c = symbols.getPercent(); break; case PATTERN_PER_MILLE: c = symbols.getPerMill(); break; case PATTERN_MINUS: c = symbols.getMinusSign(); break; } } buffer.append(c); } } } }
public class class_name { private void appendAffix(StringBuffer buffer, String affixPattern, String expAffix, boolean localized) { if (affixPattern == null) { appendAffix(buffer, expAffix, localized); // depends on control dependency: [if], data = [none] } else { int i; for (int pos=0; pos<affixPattern.length(); pos=i) { i = affixPattern.indexOf(QUOTE, pos); // depends on control dependency: [for], data = [pos] if (i < 0) { appendAffix(buffer, affixPattern.substring(pos), localized); // depends on control dependency: [if], data = [none] break; } if (i > pos) { appendAffix(buffer, affixPattern.substring(pos, i), localized); // depends on control dependency: [if], data = [none] } char c = affixPattern.charAt(++i); ++i; // depends on control dependency: [for], data = [none] if (c == QUOTE) { buffer.append(c); // depends on control dependency: [if], data = [(c] // Fall through and append another QUOTE below } else if (c == CURRENCY_SIGN && i<affixPattern.length() && affixPattern.charAt(i) == CURRENCY_SIGN) { ++i; // depends on control dependency: [if], data = [none] buffer.append(c); // depends on control dependency: [if], data = [(c] // Fall through and append another CURRENCY_SIGN below } else if (localized) { switch (c) { case PATTERN_PERCENT: c = symbols.getPercent(); break; case PATTERN_PER_MILLE: c = symbols.getPerMill(); break; case PATTERN_MINUS: c = symbols.getMinusSign(); break; } } buffer.append(c); // depends on control dependency: [for], data = [none] } } } }
public class class_name { public void setClosure(String key, Closure closure) { if (closures == null) { closures = CollectionUtil.createHashMap(Const.INITIAL_CAPACITY); } closures.put(key, closure); } }
public class class_name { public void setClosure(String key, Closure closure) { if (closures == null) { closures = CollectionUtil.createHashMap(Const.INITIAL_CAPACITY); // depends on control dependency: [if], data = [none] } closures.put(key, closure); } }
public class class_name { protected SignatureValidationConfiguration getSignatureValidationConfiguration() { val config = DefaultSecurityConfigurationBootstrap.buildDefaultSignatureValidationConfiguration(); val samlIdp = casProperties.getAuthn().getSamlIdp(); if (this.overrideBlackListedSignatureAlgorithms != null && !samlIdp.getAlgs().getOverrideBlackListedSignatureSigningAlgorithms().isEmpty()) { config.setBlacklistedAlgorithms(this.overrideBlackListedSignatureAlgorithms); config.setWhitelistMerge(true); } if (this.overrideWhiteListedAlgorithms != null && !this.overrideWhiteListedAlgorithms.isEmpty()) { config.setWhitelistedAlgorithms(this.overrideWhiteListedAlgorithms); config.setBlacklistMerge(true); } LOGGER.debug("Signature validation blacklisted algorithms: [{}]", config.getBlacklistedAlgorithms()); LOGGER.debug("Signature validation whitelisted algorithms: [{}]", config.getWhitelistedAlgorithms()); return config; } }
public class class_name { protected SignatureValidationConfiguration getSignatureValidationConfiguration() { val config = DefaultSecurityConfigurationBootstrap.buildDefaultSignatureValidationConfiguration(); val samlIdp = casProperties.getAuthn().getSamlIdp(); if (this.overrideBlackListedSignatureAlgorithms != null && !samlIdp.getAlgs().getOverrideBlackListedSignatureSigningAlgorithms().isEmpty()) { config.setBlacklistedAlgorithms(this.overrideBlackListedSignatureAlgorithms); // depends on control dependency: [if], data = [(this.overrideBlackListedSignatureAlgorithms] config.setWhitelistMerge(true); // depends on control dependency: [if], data = [none] } if (this.overrideWhiteListedAlgorithms != null && !this.overrideWhiteListedAlgorithms.isEmpty()) { config.setWhitelistedAlgorithms(this.overrideWhiteListedAlgorithms); // depends on control dependency: [if], data = [(this.overrideWhiteListedAlgorithms] config.setBlacklistMerge(true); // depends on control dependency: [if], data = [none] } LOGGER.debug("Signature validation blacklisted algorithms: [{}]", config.getBlacklistedAlgorithms()); LOGGER.debug("Signature validation whitelisted algorithms: [{}]", config.getWhitelistedAlgorithms()); return config; } }
public class class_name { public ListDomainNamesResult withDomainNames(DomainInfo... domainNames) { if (this.domainNames == null) { setDomainNames(new java.util.ArrayList<DomainInfo>(domainNames.length)); } for (DomainInfo ele : domainNames) { this.domainNames.add(ele); } return this; } }
public class class_name { public ListDomainNamesResult withDomainNames(DomainInfo... domainNames) { if (this.domainNames == null) { setDomainNames(new java.util.ArrayList<DomainInfo>(domainNames.length)); // depends on control dependency: [if], data = [none] } for (DomainInfo ele : domainNames) { this.domainNames.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { private void initSocket() { socket = new Socket(); try { socket.setSoLinger(false, 0); socket.setTcpNoDelay(true); socket.setSoTimeout(timeout); } catch (SocketException sx) { LOGGER.error("Could not configure socket.", sx); } } }
public class class_name { private void initSocket() { socket = new Socket(); try { socket.setSoLinger(false, 0); // depends on control dependency: [try], data = [none] socket.setTcpNoDelay(true); // depends on control dependency: [try], data = [none] socket.setSoTimeout(timeout); // depends on control dependency: [try], data = [none] } catch (SocketException sx) { LOGGER.error("Could not configure socket.", sx); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public final Object getEObject() { String thisMethodName = "getEObject"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); SibTr.exit(tc, thisMethodName, _me); } return _me; } }
public class class_name { public final Object getEObject() { String thisMethodName = "getEObject"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); // depends on control dependency: [if], data = [none] SibTr.exit(tc, thisMethodName, _me); // depends on control dependency: [if], data = [none] } return _me; } }
public class class_name { void emitContent(Location from, Location until, SourceHandler handler) throws SAXException { if (from.compareTo(until) >= 0) { return; } int fromLine = from.getLine(); int untilLine = until.getLine(); Line line = getLine(fromLine); if (fromLine == untilLine) { try { handler.characters(line.getBuffer(), line.getOffset() + from.getColumn(), until.getColumn() - from.getColumn()); } catch (ArrayIndexOutOfBoundsException e) { } } else { // first line int length = line.getBufferLength() - from.getColumn(); if (length > 0) { if (!((fromLine == 0 || fromLine == lines.size() - 1) && this.isCss)) { handler.characters(line.getBuffer(), line.getOffset() + from.getColumn(), length); } } if (fromLine + 1 != lines.size()) { if (!(fromLine == 0 && this.isCss)) { handler.newLine(); } } // lines in between int wholeLine = fromLine + 1; while (wholeLine < untilLine) { line = getLine(wholeLine); handler.characters(line.getBuffer(), line.getOffset(), line.getBufferLength()); wholeLine++; if (wholeLine != lines.size()) { handler.newLine(); } } // last line int untilCol = until.getColumn(); if (untilCol > 0) { line = getLine(untilLine); if (!(untilLine == lines.size() - 1 && this.isCss)) { handler.characters(line.getBuffer(), line.getOffset(), untilCol); } } } } }
public class class_name { void emitContent(Location from, Location until, SourceHandler handler) throws SAXException { if (from.compareTo(until) >= 0) { return; } int fromLine = from.getLine(); int untilLine = until.getLine(); Line line = getLine(fromLine); if (fromLine == untilLine) { try { handler.characters(line.getBuffer(), line.getOffset() + from.getColumn(), until.getColumn() - from.getColumn()); // depends on control dependency: [try], data = [none] } catch (ArrayIndexOutOfBoundsException e) { } // depends on control dependency: [catch], data = [none] } else { // first line int length = line.getBufferLength() - from.getColumn(); if (length > 0) { if (!((fromLine == 0 || fromLine == lines.size() - 1) && this.isCss)) { handler.characters(line.getBuffer(), line.getOffset() + from.getColumn(), length); // depends on control dependency: [if], data = [none] } } if (fromLine + 1 != lines.size()) { if (!(fromLine == 0 && this.isCss)) { handler.newLine(); // depends on control dependency: [if], data = [none] } } // lines in between int wholeLine = fromLine + 1; while (wholeLine < untilLine) { line = getLine(wholeLine); // depends on control dependency: [while], data = [(wholeLine] handler.characters(line.getBuffer(), line.getOffset(), line.getBufferLength()); // depends on control dependency: [while], data = [none] wholeLine++; // depends on control dependency: [while], data = [none] if (wholeLine != lines.size()) { handler.newLine(); // depends on control dependency: [if], data = [none] } } // last line int untilCol = until.getColumn(); if (untilCol > 0) { line = getLine(untilLine); // depends on control dependency: [if], data = [none] if (!(untilLine == lines.size() - 1 && this.isCss)) { handler.characters(line.getBuffer(), line.getOffset(), untilCol); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public boolean isSkipURL(URI uri) { if (patternSkipURL == null || uri == null) { return false; } String sURI = uri.toString(); return patternSkipURL.matcher(sURI).find(); } }
public class class_name { public boolean isSkipURL(URI uri) { if (patternSkipURL == null || uri == null) { return false; // depends on control dependency: [if], data = [none] } String sURI = uri.toString(); return patternSkipURL.matcher(sURI).find(); } }
public class class_name { @Override public void processValidation(Object entity) { // Si on ne doit pas evaluer cette annotation if(!this.isProcessable()) { // On sort return; } // Le Type ValidatorExpressionType type = this.getType(); // Si le type est null if(type == null) type = ValidatorExpressionType.JPQL; // Si le type est HQL|JPQL|EJBQL if(type.equals(ValidatorExpressionType.HQL) || type.equals(ValidatorExpressionType.JPQL) || type.equals(ValidatorExpressionType.EJBQL)) { // On construit la requte Query query = this.buildQuery(entity); // Execution List<Object> result = query.getResultList(); // La Taille long size = 0; // Le minimum long min = ((SizeDAOValidator) this.annotation).min(); // Le max long max = ((SizeDAOValidator) this.annotation).max(); // Si la liste n'est pas vide if(result != null && result.size() > 0) size = result.size(); // On compare if((min > size) || (max < size)) { // On lve une exception throw new DAOValidationException(getMessage(), getMessageParameters(entity)); } } } }
public class class_name { @Override public void processValidation(Object entity) { // Si on ne doit pas evaluer cette annotation if(!this.isProcessable()) { // On sort return; // depends on control dependency: [if], data = [none] } // Le Type ValidatorExpressionType type = this.getType(); // Si le type est null if(type == null) type = ValidatorExpressionType.JPQL; // Si le type est HQL|JPQL|EJBQL if(type.equals(ValidatorExpressionType.HQL) || type.equals(ValidatorExpressionType.JPQL) || type.equals(ValidatorExpressionType.EJBQL)) { // On construit la requte Query query = this.buildQuery(entity); // Execution List<Object> result = query.getResultList(); // La Taille long size = 0; // Le minimum long min = ((SizeDAOValidator) this.annotation).min(); // Le max long max = ((SizeDAOValidator) this.annotation).max(); // Si la liste n'est pas vide if(result != null && result.size() > 0) size = result.size(); // On compare if((min > size) || (max < size)) { // On lve une exception throw new DAOValidationException(getMessage(), getMessageParameters(entity)); } } } }
public class class_name { public SimpleListHolder<T> getFlatUp() { if (flatUp == null) { flatUp = newSimpleListHolder(up_to_root, getSortProperty()); } return flatUp; } }
public class class_name { public SimpleListHolder<T> getFlatUp() { if (flatUp == null) { flatUp = newSimpleListHolder(up_to_root, getSortProperty()); // depends on control dependency: [if], data = [none] } return flatUp; } }
public class class_name { public DescribeScalingActivitiesRequest withActivityIds(String... activityIds) { if (this.activityIds == null) { setActivityIds(new com.amazonaws.internal.SdkInternalList<String>(activityIds.length)); } for (String ele : activityIds) { this.activityIds.add(ele); } return this; } }
public class class_name { public DescribeScalingActivitiesRequest withActivityIds(String... activityIds) { if (this.activityIds == null) { setActivityIds(new com.amazonaws.internal.SdkInternalList<String>(activityIds.length)); // depends on control dependency: [if], data = [none] } for (String ele : activityIds) { this.activityIds.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { public List<DomainObjectType> getDomainObjectTypes() { List<DomainObjectType> resultList = new ArrayList<DomainObjectType>(); GrNode infoNode = loadDomainInfoNode(); GrProperty prop = infoNode.getProperty(DomainInfoLabel2ClassProperty); if (prop != null) { @SuppressWarnings("unchecked") List<String> val = (List<String>) prop.getValue(); for (String str : val) { String[] c2l = str.split("="); resultList.add(new DomainObjectType(c2l[1], c2l[0])); } } return resultList; } }
public class class_name { public List<DomainObjectType> getDomainObjectTypes() { List<DomainObjectType> resultList = new ArrayList<DomainObjectType>(); GrNode infoNode = loadDomainInfoNode(); GrProperty prop = infoNode.getProperty(DomainInfoLabel2ClassProperty); if (prop != null) { @SuppressWarnings("unchecked") List<String> val = (List<String>) prop.getValue(); for (String str : val) { String[] c2l = str.split("="); resultList.add(new DomainObjectType(c2l[1], c2l[0])); // depends on control dependency: [for], data = [none] } } return resultList; } }
public class class_name { @Override public void registerStatsStorageListener(StatsStorageListener listener) { if (!this.listeners.contains(listener)) { this.listeners.add(listener); } } }
public class class_name { @Override public void registerStatsStorageListener(StatsStorageListener listener) { if (!this.listeners.contains(listener)) { this.listeners.add(listener); // depends on control dependency: [if], data = [none] } } }
public class class_name { private MessageType getReadSchema(MessageType fileSchema, Path filePath) { RowTypeInfo fileTypeInfo = (RowTypeInfo) ParquetSchemaConverter.fromParquetType(fileSchema); List<Type> types = new ArrayList<>(); for (int i = 0; i < fieldNames.length; ++i) { String readFieldName = fieldNames[i]; TypeInformation<?> readFieldType = fieldTypes[i]; if (fileTypeInfo.getFieldIndex(readFieldName) < 0) { if (!skipWrongSchemaFileSplit) { throw new IllegalArgumentException("Field " + readFieldName + " cannot be found in schema of " + " Parquet file: " + filePath + "."); } else { this.skipThisSplit = true; return fileSchema; } } if (!readFieldType.equals(fileTypeInfo.getTypeAt(readFieldName))) { if (!skipWrongSchemaFileSplit) { throw new IllegalArgumentException("Expecting type " + readFieldType + " for field " + readFieldName + " but found type " + fileTypeInfo.getTypeAt(readFieldName) + " in Parquet file: " + filePath + "."); } else { this.skipThisSplit = true; return fileSchema; } } types.add(fileSchema.getType(readFieldName)); } return new MessageType(fileSchema.getName(), types); } }
public class class_name { private MessageType getReadSchema(MessageType fileSchema, Path filePath) { RowTypeInfo fileTypeInfo = (RowTypeInfo) ParquetSchemaConverter.fromParquetType(fileSchema); List<Type> types = new ArrayList<>(); for (int i = 0; i < fieldNames.length; ++i) { String readFieldName = fieldNames[i]; TypeInformation<?> readFieldType = fieldTypes[i]; if (fileTypeInfo.getFieldIndex(readFieldName) < 0) { if (!skipWrongSchemaFileSplit) { throw new IllegalArgumentException("Field " + readFieldName + " cannot be found in schema of " + " Parquet file: " + filePath + "."); } else { this.skipThisSplit = true; // depends on control dependency: [if], data = [none] return fileSchema; // depends on control dependency: [if], data = [none] } } if (!readFieldType.equals(fileTypeInfo.getTypeAt(readFieldName))) { if (!skipWrongSchemaFileSplit) { throw new IllegalArgumentException("Expecting type " + readFieldType + " for field " + readFieldName + " but found type " + fileTypeInfo.getTypeAt(readFieldName) + " in Parquet file: " + filePath + "."); } else { this.skipThisSplit = true; // depends on control dependency: [if], data = [none] return fileSchema; // depends on control dependency: [if], data = [none] } } types.add(fileSchema.getType(readFieldName)); // depends on control dependency: [for], data = [none] } return new MessageType(fileSchema.getName(), types); } }
public class class_name { private void initializeBeamSearchChart(List<Object> terminals, BeamSearchCfgParseChart chart, long[] treeEncodingOffsets) { Variable terminalListValue = terminalVar.getOnlyVariable(); // Adding this to a tree key indicates that the tree is a terminal. long terminalSignal = ((long) chart.chartSize()) * (treeEncodingOffsets[3] + treeEncodingOffsets[2]); for (int i = 0; i < terminals.size(); i++) { for (int j = i; j < terminals.size(); j++) { if (terminalListValue.canTakeValue(terminals.subList(i, j + 1))) { Assignment assignment = terminalVar.outcomeArrayToAssignment(terminals.subList(i, j + 1)); Iterator<Outcome> iterator = terminalDistribution.outcomePrefixIterator(assignment); while (iterator.hasNext()) { Outcome bestOutcome = iterator.next(); int root = nonterminalVariableType.getValueIndex(bestOutcome.getAssignment().getValue(parentVar.getOnlyVariableNum())); int ruleType = ruleVariableType.getValueIndex(bestOutcome.getAssignment().getValue(ruleTypeVar.getOnlyVariableNum())); long partialKeyNum = (root * treeEncodingOffsets[4]) + (ruleType * treeEncodingOffsets[5]); chart.addParseTreeKeyForSpan(i, j, terminalSignal + partialKeyNum, bestOutcome.getProbability()); } // System.out.println(i + "." + j + ": " + assignment + " : " + // chart.getParseTreesForSpan(i, j)); } } } } }
public class class_name { private void initializeBeamSearchChart(List<Object> terminals, BeamSearchCfgParseChart chart, long[] treeEncodingOffsets) { Variable terminalListValue = terminalVar.getOnlyVariable(); // Adding this to a tree key indicates that the tree is a terminal. long terminalSignal = ((long) chart.chartSize()) * (treeEncodingOffsets[3] + treeEncodingOffsets[2]); for (int i = 0; i < terminals.size(); i++) { for (int j = i; j < terminals.size(); j++) { if (terminalListValue.canTakeValue(terminals.subList(i, j + 1))) { Assignment assignment = terminalVar.outcomeArrayToAssignment(terminals.subList(i, j + 1)); Iterator<Outcome> iterator = terminalDistribution.outcomePrefixIterator(assignment); while (iterator.hasNext()) { Outcome bestOutcome = iterator.next(); int root = nonterminalVariableType.getValueIndex(bestOutcome.getAssignment().getValue(parentVar.getOnlyVariableNum())); int ruleType = ruleVariableType.getValueIndex(bestOutcome.getAssignment().getValue(ruleTypeVar.getOnlyVariableNum())); long partialKeyNum = (root * treeEncodingOffsets[4]) + (ruleType * treeEncodingOffsets[5]); chart.addParseTreeKeyForSpan(i, j, terminalSignal + partialKeyNum, bestOutcome.getProbability()); // depends on control dependency: [while], data = [none] } // System.out.println(i + "." + j + ": " + assignment + " : " + // chart.getParseTreesForSpan(i, j)); } } } } }
public class class_name { protected boolean isUserInfoValid(String userInfoStr, String subClaim) { String userInfoSubClaim = getUserInfoSubClaim(userInfoStr); if (userInfoSubClaim == null || subClaim == null || userInfoSubClaim.compareTo(subClaim) != 0) { Tr.error(tc, "USERINFO_INVALID", new Object[] { userInfoStr, subClaim }); return false; } return true; } }
public class class_name { protected boolean isUserInfoValid(String userInfoStr, String subClaim) { String userInfoSubClaim = getUserInfoSubClaim(userInfoStr); if (userInfoSubClaim == null || subClaim == null || userInfoSubClaim.compareTo(subClaim) != 0) { Tr.error(tc, "USERINFO_INVALID", new Object[] { userInfoStr, subClaim }); // depends on control dependency: [if], data = [none] return false; // depends on control dependency: [if], data = [none] } return true; } }
public class class_name { public static void removeValue(String registryName, String key) { Sysprop registryObject = readRegistryObject(registryName); if (registryObject == null || StringUtils.isBlank(key)) { return; } if (registryObject.hasProperty(key)) { registryObject.removeProperty(key); CoreUtils.getInstance().getDao().update(REGISTRY_APP_ID, registryObject); } } }
public class class_name { public static void removeValue(String registryName, String key) { Sysprop registryObject = readRegistryObject(registryName); if (registryObject == null || StringUtils.isBlank(key)) { return; // depends on control dependency: [if], data = [none] } if (registryObject.hasProperty(key)) { registryObject.removeProperty(key); // depends on control dependency: [if], data = [none] CoreUtils.getInstance().getDao().update(REGISTRY_APP_ID, registryObject); // depends on control dependency: [if], data = [none] } } }
public class class_name { public ISREInstall getSelectedSRE() { if (this.enableSystemWideSelector && this.systemSREButton.getSelection()) { return SARLRuntime.getDefaultSREInstall(); } if (!this.projectProviderFactories.isEmpty() && this.projectSREButton.getSelection()) { return retreiveProjectSRE(); } return getSpecificSRE(); } }
public class class_name { public ISREInstall getSelectedSRE() { if (this.enableSystemWideSelector && this.systemSREButton.getSelection()) { return SARLRuntime.getDefaultSREInstall(); // depends on control dependency: [if], data = [none] } if (!this.projectProviderFactories.isEmpty() && this.projectSREButton.getSelection()) { return retreiveProjectSRE(); // depends on control dependency: [if], data = [none] } return getSpecificSRE(); } }
public class class_name { public static void swapCols(double[][] matrix, int col1, int col2) { double temp = 0; int rows = matrix.length; double[] r = null; for (int row = 0; row < rows; row++) { r = matrix[row]; temp = r[col1]; r[col1] = r[col2]; r[col2] = temp; } } }
public class class_name { public static void swapCols(double[][] matrix, int col1, int col2) { double temp = 0; int rows = matrix.length; double[] r = null; for (int row = 0; row < rows; row++) { r = matrix[row]; // depends on control dependency: [for], data = [row] temp = r[col1]; // depends on control dependency: [for], data = [none] r[col1] = r[col2]; // depends on control dependency: [for], data = [none] r[col2] = temp; // depends on control dependency: [for], data = [none] } } }
public class class_name { private void processInstanceContentEvent(InstancesContentEvent instContentEvent){ this.numBatches++; this.contentEventList.add(instContentEvent); if (this.numBatches == 1 || this.numBatches > 4){ this.processInstances(this.contentEventList.remove(0)); } if (instContentEvent.isLastEvent()) { // drain remaining instances while (!contentEventList.isEmpty()) { processInstances(contentEventList.remove(0)); } } } }
public class class_name { private void processInstanceContentEvent(InstancesContentEvent instContentEvent){ this.numBatches++; this.contentEventList.add(instContentEvent); if (this.numBatches == 1 || this.numBatches > 4){ this.processInstances(this.contentEventList.remove(0)); // depends on control dependency: [if], data = [none] } if (instContentEvent.isLastEvent()) { // drain remaining instances while (!contentEventList.isEmpty()) { processInstances(contentEventList.remove(0)); // depends on control dependency: [while], data = [none] } } } }
public class class_name { public static void interleave(AudioFormat format, ByteBuffer[] ins, ByteBuffer outb) { int bytesPerSample = format.getSampleSizeInBits() >> 3; int bytesPerFrame = bytesPerSample * ins.length; int max = 0; for (int i = 0; i < ins.length; i++) if (ins[i].remaining() > max) max = ins[i].remaining(); for (int frames = 0; frames < max && outb.remaining() >= bytesPerFrame; frames++) { for (int j = 0; j < ins.length; j++) { if (ins[j].remaining() < bytesPerSample) { for (int i = 0; i < bytesPerSample; i++) outb.put((byte) 0); } else { for (int i = 0; i < bytesPerSample; i++) { outb.put(ins[j].get()); } } } } } }
public class class_name { public static void interleave(AudioFormat format, ByteBuffer[] ins, ByteBuffer outb) { int bytesPerSample = format.getSampleSizeInBits() >> 3; int bytesPerFrame = bytesPerSample * ins.length; int max = 0; for (int i = 0; i < ins.length; i++) if (ins[i].remaining() > max) max = ins[i].remaining(); for (int frames = 0; frames < max && outb.remaining() >= bytesPerFrame; frames++) { for (int j = 0; j < ins.length; j++) { if (ins[j].remaining() < bytesPerSample) { for (int i = 0; i < bytesPerSample; i++) outb.put((byte) 0); } else { for (int i = 0; i < bytesPerSample; i++) { outb.put(ins[j].get()); // depends on control dependency: [for], data = [none] } } } } } }
public class class_name { @Override public QueryDefinition registerQuery(QueryDefinition queryDefinition) { QueryDefinition result = null; if (config.isRest()) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(QUERY_NAME, queryDefinition.getName()); result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + CREATE_QUERY_DEF_POST_URI, valuesMap), queryDefinition, QueryDefinition.class); } else { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "registerQuery", serialize(queryDefinition), marshaller.getFormat().getType(), new Object[]{queryDefinition.getName()}))); ServiceResponse<QueryDefinition> response = (ServiceResponse<QueryDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = response.getResult(); } return result; } }
public class class_name { @Override public QueryDefinition registerQuery(QueryDefinition queryDefinition) { QueryDefinition result = null; if (config.isRest()) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(QUERY_NAME, queryDefinition.getName()); // depends on control dependency: [if], data = [none] result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + CREATE_QUERY_DEF_POST_URI, valuesMap), queryDefinition, QueryDefinition.class); // depends on control dependency: [if], data = [none] } else { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "registerQuery", serialize(queryDefinition), marshaller.getFormat().getType(), new Object[]{queryDefinition.getName()}))); ServiceResponse<QueryDefinition> response = (ServiceResponse<QueryDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0); throwExceptionOnFailure(response); // depends on control dependency: [if], data = [none] if (shouldReturnWithNullResponse(response)) { return null; // depends on control dependency: [if], data = [none] } result = response.getResult(); // depends on control dependency: [if], data = [none] } return result; } }
public class class_name { private void populateMap(byte[] data, Integer previousItemOffset, Integer previousItemKey, Integer itemOffset) { if (previousItemOffset != null) { int itemSize = itemOffset.intValue() - previousItemOffset.intValue(); byte[] itemData = new byte[itemSize]; System.arraycopy(data, previousItemOffset.intValue(), itemData, 0, itemSize); m_map.put(previousItemKey, itemData); } } }
public class class_name { private void populateMap(byte[] data, Integer previousItemOffset, Integer previousItemKey, Integer itemOffset) { if (previousItemOffset != null) { int itemSize = itemOffset.intValue() - previousItemOffset.intValue(); byte[] itemData = new byte[itemSize]; System.arraycopy(data, previousItemOffset.intValue(), itemData, 0, itemSize); // depends on control dependency: [if], data = [none] m_map.put(previousItemKey, itemData); // depends on control dependency: [if], data = [none] } } }
public class class_name { public HClient createClient(CassandraHost ch) { if (log.isDebugEnabled()) { log.debug("Creation of new client"); } if (params == null) return new HSaslThriftClient(ch, krbServicePrincipalName); else return new HSaslThriftClient(ch, krbServicePrincipalName, params); } }
public class class_name { public HClient createClient(CassandraHost ch) { if (log.isDebugEnabled()) { log.debug("Creation of new client"); // depends on control dependency: [if], data = [none] } if (params == null) return new HSaslThriftClient(ch, krbServicePrincipalName); else return new HSaslThriftClient(ch, krbServicePrincipalName, params); } }
public class class_name { public static IAtomContainerSet detect(IAtomContainer ac) { IAtomContainerSet piSystemSet = ac.getBuilder().newInstance(IAtomContainerSet.class); for (int i = 0; i < ac.getAtomCount(); i++) { IAtom atom = ac.getAtom(i); atom.setFlag(CDKConstants.VISITED, false); } for (int i = 0; i < ac.getAtomCount(); i++) { IAtom firstAtom = ac.getAtom(i); // if this atom was already visited in a previous DFS, continue if (firstAtom.getFlag(CDKConstants.VISITED) || checkAtom(ac, firstAtom) == -1) { continue; } IAtomContainer piSystem = ac.getBuilder().newInstance(IAtomContainer.class); Stack<IAtom> stack = new Stack<IAtom>(); piSystem.addAtom(firstAtom); stack.push(firstAtom); firstAtom.setFlag(CDKConstants.VISITED, true); // Start DFS from firstAtom while (!stack.empty()) { //boolean addAtom = false; IAtom currentAtom = stack.pop(); List<IAtom> atoms = ac.getConnectedAtomsList(currentAtom); List<IBond> bonds = ac.getConnectedBondsList(currentAtom); for (int j = 0; j < atoms.size(); j++) { IAtom atom = atoms.get(j); IBond bond = bonds.get(j); if (!atom.getFlag(CDKConstants.VISITED)) { int check = checkAtom(ac, atom); if (check == 1) { piSystem.addAtom(atom); piSystem.addBond(bond); continue; // do not mark atom as visited if cumulative double bond } else if (check == 0) { piSystem.addAtom(atom); piSystem.addBond(bond); stack.push(atom); } atom.setFlag(CDKConstants.VISITED, true); } // close rings with one bond else if (!piSystem.contains(bond) && piSystem.contains(atom)) { piSystem.addBond(bond); } } } if (piSystem.getAtomCount() > 2) { piSystemSet.addAtomContainer(piSystem); } } return piSystemSet; } }
public class class_name { public static IAtomContainerSet detect(IAtomContainer ac) { IAtomContainerSet piSystemSet = ac.getBuilder().newInstance(IAtomContainerSet.class); for (int i = 0; i < ac.getAtomCount(); i++) { IAtom atom = ac.getAtom(i); atom.setFlag(CDKConstants.VISITED, false); // depends on control dependency: [for], data = [none] } for (int i = 0; i < ac.getAtomCount(); i++) { IAtom firstAtom = ac.getAtom(i); // if this atom was already visited in a previous DFS, continue if (firstAtom.getFlag(CDKConstants.VISITED) || checkAtom(ac, firstAtom) == -1) { continue; } IAtomContainer piSystem = ac.getBuilder().newInstance(IAtomContainer.class); Stack<IAtom> stack = new Stack<IAtom>(); piSystem.addAtom(firstAtom); // depends on control dependency: [for], data = [none] stack.push(firstAtom); // depends on control dependency: [for], data = [none] firstAtom.setFlag(CDKConstants.VISITED, true); // depends on control dependency: [for], data = [none] // Start DFS from firstAtom while (!stack.empty()) { //boolean addAtom = false; IAtom currentAtom = stack.pop(); List<IAtom> atoms = ac.getConnectedAtomsList(currentAtom); List<IBond> bonds = ac.getConnectedBondsList(currentAtom); for (int j = 0; j < atoms.size(); j++) { IAtom atom = atoms.get(j); IBond bond = bonds.get(j); if (!atom.getFlag(CDKConstants.VISITED)) { int check = checkAtom(ac, atom); if (check == 1) { piSystem.addAtom(atom); // depends on control dependency: [if], data = [none] piSystem.addBond(bond); // depends on control dependency: [if], data = [none] continue; // do not mark atom as visited if cumulative double bond } else if (check == 0) { piSystem.addAtom(atom); // depends on control dependency: [if], data = [none] piSystem.addBond(bond); // depends on control dependency: [if], data = [none] stack.push(atom); // depends on control dependency: [if], data = [none] } atom.setFlag(CDKConstants.VISITED, true); // depends on control dependency: [if], data = [none] } // close rings with one bond else if (!piSystem.contains(bond) && piSystem.contains(atom)) { piSystem.addBond(bond); // depends on control dependency: [if], data = [none] } } } if (piSystem.getAtomCount() > 2) { piSystemSet.addAtomContainer(piSystem); // depends on control dependency: [if], data = [none] } } return piSystemSet; } }
public class class_name { private static long hash(byte[] input) { long hash = FNV1_INIT; for (byte b : input) { hash ^= b & 0xff; hash *= FNV1_PRIME; } return hash; } }
public class class_name { private static long hash(byte[] input) { long hash = FNV1_INIT; for (byte b : input) { hash ^= b & 0xff; // depends on control dependency: [for], data = [b] hash *= FNV1_PRIME; // depends on control dependency: [for], data = [none] } return hash; } }