rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
private ArrayList scanDirectory (File path) | private ArrayList scanDirectory(File path) | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
Debug.trace ("scanning directory " + path.getAbsolutePath()); | Debug.trace("scanning directory " + path.getAbsolutePath()); | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
ArrayList result = new ArrayList (); | ArrayList result = new ArrayList(); | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
if (! path.isDirectory ()) | if (!path.isDirectory()) | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
File[] entries = path.listFiles (); | File[] entries = path.listFiles(); | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
if (f == null) continue; if (f.isDirectory ()) | if (f == null) continue; if (f.isDirectory()) | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) | result.addAll(scanDirectory(f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith(".java"))) | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
result.add (f); | result.add(f); | private ArrayList scanDirectory (File path) { Debug.trace ("scanning directory " + path.getAbsolutePath()); ArrayList result = new ArrayList (); if (! path.isDirectory ()) return result; File[] entries = path.listFiles (); for (int i = 0; i < entries.length; i++) { File f = entries[i]; if (f == null) continue; if (f.isDirectory ()) { result.addAll (scanDirectory (f)); } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith (".java"))) { result.add (f); } } return result; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
public void setCompiler (String compiler) | public void setCompiler(String compiler) | public void setCompiler (String compiler) { this.compilerToUse = compiler; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
public void setCompilerArguments (String arguments) | public void setCompilerArguments(String arguments) | public void setCompilerArguments (String arguments) { this.compilerArgumentsToUse = arguments; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
public void startThread () | public void startThread() | public void startThread () { this.compilationThread = new Thread (this, "compilation thread"); //will call this.run() this.compilationThread.start(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
this.compilationThread = new Thread (this, "compilation thread"); | this.compilationThread = new Thread(this, "compilation thread"); | public void startThread () { this.compilationThread = new Thread (this, "compilation thread"); //will call this.run() this.compilationThread.start(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/CompileWorker.java/clean/src/lib/com/izforge/izpack/installer/CompileWorker.java |
infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); | infoLabel = new JLabel( parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); | public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/HTMLInfoPanel.java/clean/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java |
} catch (Exception err) | } catch (Exception err) | public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/HTMLInfoPanel.java/clean/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java |
catch (Exception err) {} | public void hyperlinkUpdate(HyperlinkEvent e) { try { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) textArea.setPage(e.getURL()); } catch (Exception err) {} } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/HTMLInfoPanel.java/clean/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java |
|
} catch (Exception ex) | } catch (Exception ex) | private URL loadInfo() { String resNamePrifix = "HTMLInfoPanel.info"; try { return ResourceManager.getInstance().getURL(resNamePrifix); } catch (Exception ex) { ex.printStackTrace(); } return null; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/HTMLInfoPanel.java/clean/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java |
_logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); | _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " and " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); | private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
String paths = ""; | String paths = "The route is: "; | private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
paths += " ==> " + getCompleteEdgeName( item ); | paths += getCompleteEdgeName( item ) + " ==> "; | private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
paths += " Done!"; | private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
|
private void parseFile( String fileName ) | private SparseGraph parseFile( String fileName ) | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
||
DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); | DirectedSparseVertex v = (DirectedSparseVertex) graph.addVertex( new DirectedSparseVertex() ); | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); | p = Pattern.compile( "(NO_MERGE)", Pattern.MULTILINE ); | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
_logger.debug( "Found no merge for edge: " + label ); | _logger.debug( "Found NO_MERGE for edge: " + label ); | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
Object[] vertices = _graph.getVertices().toArray(); | Object[] vertices = graph.getVertices().toArray(); | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
_graph.addEdge( e ); | graph.addEdge( e ); | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
return graph; | private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
|
parseFile( _graphmlFileName ); | _graph = parseFile( _graphmlFileName ); | private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
parseFile( allChildren[ i ].getAbsolutePath() ); | _graphList.add( parseFile( allChildren[ i ].getAbsolutePath() ) ); | private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
mergeVertices(); | analyseSubGraphs(); | private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
Indexer id = Indexer.getIndexer( _graph ); | Indexer id = Indexer.getAndUpdateIndexer( _graph ); | public void writeGraph( String mergedGraphml_ ) { StringBuffer sourceFile = new StringBuffer(); try { FileWriter file = new FileWriter( mergedGraphml_ ); sourceFile.append( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ); sourceFile.append( "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns/graphml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns/graphml http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd\" xmlns:y=\"http://www.yworks.com/xml/graphml\">\n" ); sourceFile.append( " <key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>\n" ); sourceFile.append( " <key id=\"d1\" for=\"edge\" yfiles.type=\"edgegraphics\"/>\n" ); sourceFile.append( " <graph id=\"G\" edgedefault=\"directed\">\n" ); int numVertices = _graph.getVertices().size(); Indexer id = Indexer.getIndexer( _graph ); for ( int i = 0; i < numVertices; i++ ) { Vertex v = (Vertex) id.getVertex(i); int vId = i+1; sourceFile.append( " <node id=\"n" + vId + "\">\n" ); sourceFile.append( " <data key=\"d0\" >\n" ); sourceFile.append( " <y:ShapeNode >\n" ); sourceFile.append( " <y:Geometry x=\"241.875\" y=\"158.701171875\" width=\"95.0\" height=\"30.0\"/>\n" ); sourceFile.append( " <y:Fill color=\"#CCCCFF\" transparent=\"false\"/>\n" ); sourceFile.append( " <y:BorderStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:NodeLabel x=\"1.5\" y=\"5.6494140625\" width=\"92.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"internal\" modelPosition=\"c\" autoSizePolicy=\"content\">" + v.getUserDatum( LABEL_KEY ) + "</y:NodeLabel>\n" ); sourceFile.append( " <y:Shape type=\"rectangle\"/>\n" ); sourceFile.append( " </y:ShapeNode>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </node>\n" ); } int i = 0; for ( Iterator edgeIterator = _graph.getEdges().iterator(); edgeIterator.hasNext(); ) { Edge e = (Edge) edgeIterator.next(); Pair p = e.getEndpoints(); Vertex src = (Vertex) p.getFirst(); Vertex dest = (Vertex) p.getSecond(); int srcId = id.getIndex(src)+1; int destId = id.getIndex(dest)+1; int nId = ++i; sourceFile.append( " <edge id=\"" + nId + "\" source=\"n" + srcId + "\" target=\"n" + destId + "\">\n" ); sourceFile.append( " <data key=\"d1\" >\n" ); sourceFile.append( " <y:PolyLineEdge >\n" ); sourceFile.append( " <y:Path sx=\"-23.75\" sy=\"15.0\" tx=\"-23.75\" ty=\"-15.0\">\n" ); sourceFile.append( " <y:Point x=\"273.3125\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " <y:Point x=\"265.625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " </y:Path>\n" ); sourceFile.append( " <y:LineStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:Arrows source=\"none\" target=\"standard\"/>\n" ); sourceFile.append( " <y:EdgeLabel x=\"-148.25\" y=\"30.000000000000014\" width=\"169.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"free\" modelPosition=\"anywhere\" preferredPlacement=\"on_edge\" distance=\"2.0\" ratio=\"0.5\">" + e.getUserDatum( LABEL_KEY ) + "</y:EdgeLabel>\n" ); sourceFile.append( " <y:BendStyle smoothed=\"false\"/>\n" ); sourceFile.append( " </y:PolyLineEdge>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </edge>\n" ); } sourceFile.append( " </graph>\n" ); sourceFile.append( "</graphml>\n" ); file.write( sourceFile.toString() ); file.flush(); _logger.info( "Wrote: " + mergedGraphml_ ); } catch (IOException e) { e.printStackTrace(); } } | 54457 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54457/1f49f2f41d383b2f4104d9eed9d837951c0ea87b/ModelBasedTesting.java/clean/mbt/src/org/tigris/mbt/ModelBasedTesting.java |
JLabel infoLabel = createLabel(getI18nStringForClass("info", "TargetPanel"), "open", | JLabel infoLabel = createLabel("info", "TargetPanel", "open", | public PathInputPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // Set default values emptyTargetMsg = getI18nStringForClass("empty_target", "TargetPanel"); warnMsg = getI18nStringForClass("warn", "TargetPanel"); // if( this.class.) // Customize the default GridBagConstraints. GridBagConstraints gbConstraint = getDefaultGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; this.setDefaultGridBagConstraints(gbConstraint); String introText = getI18nStringForClass("intro", "PathInputPanel"); if (introText == null || introText.startsWith("PathInputPanel.intro")) introText = ""; // Intro // Create and customize constraint for it. // row 0 column 0 gbConstraint = getNextYGridBagConstraints(); // Create component and add it to this panel. MultiLineLabel introLabel = createMultiLineLabel(introText); add(introLabel, gbConstraint); // Label for input // Create and customize constraint for it. // row 1 column 0; is the next Y gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.RELATIVE; gbConstraint.insets = new Insets(0, 0, 10, 0); // Create component and add it to this panel. JLabel infoLabel = createLabel(getI18nStringForClass("info", "TargetPanel"), "open", JLabel.LEFT); add(infoLabel, gbConstraint); // Create path selection components and add they to this panel. pathSelectionPanel = new PathSelectionPanel(this, idata); gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; gbConstraint.fill = GridBagConstraints.HORIZONTAL; gbConstraint.insets = new Insets(0, 0, 0, 0); add(pathSelectionPanel, gbConstraint); createLayoutBottom(); // Place a footer as last component, if completeGridBagLayout(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/c8304bd275b449f44187bc3547148189a494456e/PathInputPanel.java/buggy/src/lib/com/izforge/izpack/panels/PathInputPanel.java |
protected KeyedObjectPool makeEmptyPool(int mincapacity) { | protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) { | protected KeyedObjectPool makeEmptyPool(int mincapacity) { if (this.getClass() != TestBaseKeyedObjectPool.class) { throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement this method."); } throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation."); } | 50977 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50977/1313111fc820c43662b3b98672f70316d84ee80c/TestBaseKeyedObjectPool.java/buggy/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java |
if( entries != null ) | private void addSelectionList(File groups, int aGridx, int aGridy, int aGridwidth, int aGridheight, int aFill) { Vector dirEntries = new Vector(); File[] entries = groups.listFiles(); for (int idx = 0; idx < entries.length; idx++) { if (entries[idx].isDirectory()) { dirEntries.add(entries[idx].getName()); } } groupList = new JList(dirEntries); groupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); groupList.getSelectionModel().addListSelectionListener(this); JScrollPane scrollPane = new JScrollPane(groupList); constraints.gridx = aGridx; constraints.gridy = aGridy; constraints.gridwidth = aGridwidth; constraints.gridheight = aGridheight; constraints.weightx = 10.0; constraints.weighty = 1.5; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = aFill; layout.addLayoutComponent(scrollPane, constraints); add(scrollPane); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7b685b77fb1c70bb5e8b01ada07311b47f884523/ShortcutPanel.java/buggy/src/lib/com/izforge/izpack/panels/ShortcutPanel.java |
|
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception | public StdKunststoffPackager( String outputFilename, PackagerListener plistener) throws Exception | public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/StdKunststoffPackager.java/buggy/src/lib/com/izforge/izpack/compiler/StdKunststoffPackager.java |
else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } | public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/StdKunststoffPackager.java/buggy/src/lib/com/izforge/izpack/compiler/StdKunststoffPackager.java |
|
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/StdKunststoffPackager.java/buggy/src/lib/com/izforge/izpack/compiler/StdKunststoffPackager.java |
||
if (zentry.isDirectory()) continue; | if (zentry.isDirectory()) continue; | public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/StdKunststoffPackager.java/buggy/src/lib/com/izforge/izpack/compiler/StdKunststoffPackager.java |
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/6e8ab3930a21f787bcd0f3cf0b9937f9d50c80c0/StdKunststoffPackager.java/buggy/src/lib/com/izforge/izpack/compiler/StdKunststoffPackager.java |
||
if (method.equals("getFreeSpace")) | if ("getFreeSpace".equals(method)) | public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/IoHelper.java/buggy/src/lib/com/izforge/izpack/util/IoHelper.java |
else if (method.equals("chmod")) | else if ("chmod".equals(method)) | public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/IoHelper.java/buggy/src/lib/com/izforge/izpack/util/IoHelper.java |
else if (method.equals("copyFile")) | else if ("copyFile".equals(method)) | public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/IoHelper.java/buggy/src/lib/com/izforge/izpack/util/IoHelper.java |
else if (method.equals("getPrimaryGroup")) | else if ("getPrimaryGroup".equals(method)) | public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/IoHelper.java/buggy/src/lib/com/izforge/izpack/util/IoHelper.java |
else if (method.equals("getenv")) | else if ("getenv".equals(method)) | public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/IoHelper.java/buggy/src/lib/com/izforge/izpack/util/IoHelper.java |
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
private void generateTROEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { int size = p_reactionModel.getReactionSet().size(); TROEODEReaction [] result = new TROEODEReaction[size]; int thirdID = 0; Iterator iter = p_reactionModel.getReactionSet().iterator(); while (iter.hasNext()) { Reaction r = (Reaction)iter.next(); if (r instanceof TROEReaction) { thirdID++; TROEODEReaction or = (TROEODEReaction)transferReaction(r, p_beginStatus, p_temperature, p_pressure); result[thirdID-1] = or; } } troeReactionList = new TROEODEReaction[thirdID]; for (int i = 0; i < thirdID; i++) { troeReactionList[i] = result[i]; } return; } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
thirdBody.add((ThirdBodyReaction)r); | public void generateThirdBodyReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generateThirdBodyReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) int size = p_reactionModel.getReactionSet().size(); ThirdBodyODEReaction [] result = new ThirdBodyODEReaction[size]; int thirdID = 0; Iterator iter = p_reactionModel.getReactionSet().iterator(); while (iter.hasNext()) { Reaction r = (Reaction)iter.next(); if ((r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { thirdID++; ThirdBodyODEReaction or = (ThirdBodyODEReaction)transferReaction(r, p_beginStatus, p_temperature, p_pressure); result[thirdID-1] = or; } } thirdBodyReactionList = new ThirdBodyODEReaction[thirdID]; for (int i = 0; i < thirdID; i++) { thirdBodyReactionList[i] = result[i]; } return; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
|
nParameter = rList.size()+thirdBodyReactionList.length; | nParameter = rList.size()+thirdBodyReactionList.length+troeReactionList.length; | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ | for (int i = 1; i <= rList.size()+thirdBodyReactionList.length+troeReactionList.length; i++){ | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ | for (int i=rList.size()+1+thirdBodyReactionList.length+troeReactionList.length; i<=nParameter;i++){ | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
int reactionNumber = rList.size()+thirdBodyReactionList.length; | int reactionNumber = rList.size()+thirdBodyReactionList.length+troeReactionList.length; | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
int speciesNum = p-rList.size()-thirdBodyReactionList.length; | int speciesNum = p-rList.size()-thirdBodyReactionList.length-troeReactionList.length; | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
Reaction rxn = (Reaction)rList.get(p); | rxn = (Reaction) rList.get(p); } else if (p < rList.size()+thirdBodyReactionList.length){ rxn = (Reaction)thirdBody.get(p-rList.size()); } else{ rxn = (Reaction)troe.get(p-rList.size()-thirdBodyReactionList.length); } | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
} else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
|
int reactionNumber = rList.size(); | int reactionNumber = rList.size()+thirdBodyReactionList.length+troeReactionList.length; | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); | idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, troeReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
sss.setReactionList(rList); | LinkedList reactionList = new LinkedList(); reactionList.addAll(rList); reactionList.addAll(thirdBody); reactionList.addAll(troe); sss.setReactionList(reactionList); | public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] } | 58381 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/58381/f535dfbbe9b4499d90bf09b749aff992198aac05/JDASPK.java/clean/jing/rxnSys/JDASPK.java |
||
public synchronized void addObject() throws Exception { | public void addObject() throws Exception { | public synchronized void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); } | 50977 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50977/1cf205e1f6c8aeaba48a8beaa3a7c345ab7eeefe/GenericObjectPool.java/buggy/src/java/org/apache/commons/pool/impl/GenericObjectPool.java |
_numActive++; this.returnObject(obj); | synchronized(this) { _numActive++; this.returnObject(obj); } | public synchronized void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); } | 50977 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50977/1cf205e1f6c8aeaba48a8beaa3a7c345ab7eeefe/GenericObjectPool.java/buggy/src/java/org/apache/commons/pool/impl/GenericObjectPool.java |
layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); | GridBagLayout layout = new GridBagLayout(); GridBagConstraints gbConstraints = new GridBagConstraints(); | protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/ImgPacksPanel.java/clean/src/lib/com/izforge/izpack/panels/ImgPacksPanel.java |
descriptionScroller = new JScrollPane(); | JScrollPane descriptionScroller = new JScrollPane(); | protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/ImgPacksPanel.java/clean/src/lib/com/izforge/izpack/panels/ImgPacksPanel.java |
int maxWidth = 80, maxHeight = 60; | int maxWidth = 80; int maxHeight = 60; | private Dimension getPreferredSizeFromImages() { int maxWidth = 80, maxHeight = 60; ImageIcon icon; for (Iterator it = images.iterator(); it.hasNext();) { icon = (ImageIcon) it.next(); maxWidth = Math.max(maxWidth, icon.getIconWidth()); maxHeight = Math.max(maxHeight, icon.getIconHeight()); } maxWidth = Math.min(maxWidth + 20, idata.guiPrefs.width - 150); maxHeight = Math.min(maxHeight + 20, idata.guiPrefs.height - 150); return new Dimension(maxWidth, maxHeight); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/ImgPacksPanel.java/clean/src/lib/com/izforge/izpack/panels/ImgPacksPanel.java |
layout = new GridBagLayout(); | GridBagLayout layout = new GridBagLayout(); | private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/UninstallerFrame.java/clean/src/lib/com/izforge/izpack/uninstaller/UninstallerFrame.java |
gbConstraints = new GridBagConstraints(); | GridBagConstraints gbConstraints = new GridBagConstraints(); | private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/UninstallerFrame.java/clean/src/lib/com/izforge/izpack/uninstaller/UninstallerFrame.java |
warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons | JLabel warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons | private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/9619b3a25f43787dc92011111668210e06c00c71/UninstallerFrame.java/clean/src/lib/com/izforge/izpack/uninstaller/UninstallerFrame.java |
return shortcut.getLinkPath(shortcut.getUserType()); | String result = shortcut.getLinkPath(shortcut.getUserType()); Debug.log( CLASS + myClass + ".getBasePath() '" + result + "'" ); return result; | public String getBasePath() throws Exception { return shortcut.getLinkPath(shortcut.getUserType()); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return (shortcut.getDirectoryCreated()); | String directoryCreated = shortcut.getDirectoryCreated(); Debug.log( CLASS + myClass + ".getDirectoryCreated() '" + directoryCreated + "'" ); return( directoryCreated ); | public String getDirectoryCreated() { return (shortcut.getDirectoryCreated()); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return (shortcut.getFileName()); | String aFilename = shortcut.getFileName(); Debug.log( CLASS + myClass + ".getFileName() '" + aFilename + "'" ); return( aFilename ); | public String getFileName() { return (shortcut.getFileName()); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return shortcut.getHotkey(); | int result = shortcut.getHotkey(); Debug.log( CLASS + myClass + ".getHotkey() '" + result + "'" ); return result; | public int getHotkey() { return shortcut.getHotkey(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return shortcut.getIconLocation(); | String result = shortcut.getIconLocation(); Debug.log( CLASS + myClass + ".getIconLocation() '" + result + "'" ); return result; | public String getIconLocation() { return shortcut.getIconLocation(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); | public int getLinkType() { int typ = shortcut.getLinkType(); switch (typ) { case ShellLink.DESKTOP: typ = DESKTOP; break; case ShellLink.PROGRAM_MENU: typ = APPLICATIONS; break; case ShellLink.START_MENU: typ = START_MENU; break; case ShellLink.STARTUP: typ = START_UP; break; default: break; } return typ; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
if (file[i].isDirectory()) | File aFile = file[i]; String aFilename = aFile.getName(); if (aFile.isDirectory()) | public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { groups.add(file[i].getName()); } } } return (groups); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
groups.add(file[i].getName()); | Debug.log( CLASS + myClass + ".getProgramGroups()-" + logentry++ + " '" + aFilename + "'" ); groups.add( aFilename ); | public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { groups.add(file[i].getName()); } } } return (groups); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
else Debug.log( CLASS + myClass + ".getProgramGroups()-" + logentry++ + " Skip (NoDirectory): '" + aFilename + "'" ); | public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { groups.add(file[i].getName()); } } } return (groups); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
public String getProgramsFolder(int current_user) | public String getProgramsFolder(int current_user) | public String getProgramsFolder(int current_user) { return shortcut.getLinkPath(current_user); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return shortcut.getLinkPath(current_user); | String result = null; try { result = new String( shortcut.getLinkPath(current_user).getBytes( StringTool.getPlatformEncoding() ), StringTool.getPlatformEncoding() ); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Debug.log( CLASS + myClass + ".getProgramsFolder() '" + current_user + "', '" + result + "'" ); return result; | public String getProgramsFolder(int current_user) { return shortcut.getLinkPath(current_user); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
{ | { | public int getShowCommand() { int showCommand = shortcut.getShowCommand(); switch (showCommand) { case ShellLink.NORMAL: showCommand = NORMAL; break; // both MINNOACTIVE and MINIMIZED map to Shortcut.MINIMIZED case ShellLink.MINNOACTIVE: case ShellLink.MINIMIZED: showCommand = MINIMIZED; break; case ShellLink.MAXIMIZED: showCommand = MAXIMIZED; break; default: break; } return showCommand; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
Debug.log( CLASS + myClass + ".getShowCommand() '" + Integer.toString(showCommand) + "'" ); | public int getShowCommand() { int showCommand = shortcut.getShowCommand(); switch (showCommand) { case ShellLink.NORMAL: showCommand = NORMAL; break; // both MINNOACTIVE and MINIMIZED map to Shortcut.MINIMIZED case ShellLink.MINNOACTIVE: case ShellLink.MINIMIZED: showCommand = MINIMIZED; break; case ShellLink.MAXIMIZED: showCommand = MAXIMIZED; break; default: break; } return showCommand; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
Debug.log( CLASS + myClass + ".getUserType() '" + utype + "'" ); | public int getUserType() { int utype = shortcut.getUserType(); switch (utype) { case ShellLink.ALL_USERS: utype = ALL_USERS; break; case ShellLink.CURRENT_USER: utype = CURRENT_USER; break; } return utype; } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
return shortcut.getWorkingDirectory(); | String result = shortcut.getWorkingDirectory(); Debug.log( CLASS + myClass + ".getWorkingDirectory() '" + result + "'" ); return result; | public String getWorkingDirectory() { return shortcut.getWorkingDirectory(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
Debug.log( CLASS + myClass + ".initialize() '" + Integer.toString(type)+ "', '" + name + "'" ); | public void initialize(int type, String name) throws Exception { switch (type) { case APPLICATIONS: { shortcut = new ShellLink(ShellLink.PROGRAM_MENU, name); break; } case START_MENU: { shortcut = new ShellLink(ShellLink.START_MENU, name); break; } case DESKTOP: { shortcut = new ShellLink(ShellLink.DESKTOP, name); break; } case START_UP: { shortcut = new ShellLink(ShellLink.STARTUP, name); break; } default: { shortcut = new ShellLink(ShellLink.PROGRAM_MENU, name); break; } } } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); | String allUsers = shortcut.getallUsersLinkPath(); Debug.log( CLASS + myClass + ".multipleUsers()-1 '" + allUsers + "'" ); String currentUsers = shortcut.getcurrentUserLinkPath(); Debug.log( CLASS + myClass + ".multipleUsers()-2 '" + currentUsers + "'" ); | public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
if (au == null || cu == null) return false; | if( allUsers == null || currentUsers == null ) result = false; else result = allUsers.length() > 0 && currentUsers.length() > 0; | public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
return (au.length() > 0 && cu.length() > 0); | Debug.log( CLASS + myClass + ".multipleUsers()-3 '" + result + "'" ); return (result); | public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
public void save() throws Exception { shortcut.save(); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
||
shortcut.setArguments(arguments); | Debug.log( CLASS + myClass + ".setArguments() '" + arguments + "'" ); shortcut.setArguments(arguments); | public void setArguments(String arguments) { shortcut.setArguments(arguments); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
shortcut.setDescription(description); | Debug.log( CLASS + myClass + ".setDescription() '" + description + "'" ); shortcut.setDescription( description ); | public void setDescription(String description) { shortcut.setDescription(description); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
Debug.log( CLASS + myClass + ".setHotkey() '" + hotkey + "'" ); | public void setHotkey(int hotkey) { shortcut.setHotkey(hotkey); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
|
shortcut.setIconLocation(path, index); | Debug.log( CLASS + myClass + ".setIconLocation() '" + path + "', '" + Integer.toString(index) + "'" ); shortcut.setIconLocation(path, index); | public void setIconLocation(String path, int index) { shortcut.setIconLocation(path, index); } | 54145 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54145/7fd6ecbf32a2883982eeb962733f98fd00021076/Win_Shortcut.java/clean/src/lib/com/izforge/izpack/util/os/Win_Shortcut.java |
Subsets and Splits